Skip to content

Commit 080a86d

Browse files
authored
Version 0.2.2 (#41)
* Update spec to version 0.2.2 * Update readme for 0.2.2 * Update nuspec
1 parent 08e2e2a commit 080a86d

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

CommandLineParser/CommandLineParser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>MatthiWare.CommandLine</RootNamespace>
66
<PackageId>MatthiWare.CommandLineParser</PackageId>
7-
<Version>0.2.1</Version>
7+
<Version>0.2.2</Version>
88
<Authors>Matthias Beerens</Authors>
99
<Company>MatthiWare</Company>
1010
<Product>Command Line Parser</Product>

CommandLineParser/CommandLineParser.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>MatthiWare.CommandLineParser</id>
5-
<version>0.2.1</version>
5+
<version>0.2.2</version>
66
<title>CommandLineParser.Core</title>
77
<authors>Matthias Beerens</authors>
88
<owners>Matthiee</owners>
@@ -15,8 +15,8 @@
1515
Configuration is done through a option model class using attributes or fluent API can be used to configure the properties of the class.
1616
This library allows to add commands with their own set of options as well.
1717
</description>
18-
<summary>A simple, light-weight and strongly typed command line parser. Configuration using fluent API and an options class. </summary>
19-
<releaseNotes>Fix issue where optional commands would be marked as missing. Fix issue where auto executing commands can cause parser to crash.</releaseNotes>
18+
<summary>A simple, light-weight and strongly typed command line parser. Configuration using Fluent API, Attributes and model classes.</summary>
19+
<releaseNotes>Fix issue with bool parsing, fix indenting, fix auto printing of errors</releaseNotes>
2020
<copyright>Copyright Matthias Beerens 2018</copyright>
2121
<tags>commandline parser commandline-parser</tags>
2222
</metadata>

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</p>
1515

1616
# CommandLineParser
17-
A simple, light-weight and strongly typed commandline parser made in .Net standard.
17+
A simple, light-weight and strongly typed commandline parser made in .NET Standard!
1818

1919
## Installation
2020
```powershell
@@ -23,35 +23,40 @@ PM> Install-Package MatthiWare.CommandLineParser
2323

2424
# Quick Start
2525

26-
First of all you need to add the nuget package.
27-
28-
Now you can setup the command line parser.
26+
Example of configuring the port option using the Fluent API.
2927

3028
``` csharp
3129
static void Main(string[] args)
3230
{
3331
// create the parser
3432
var parser = new CommandLineParser<ServerOptions>();
3533

36-
// configure the options using the fluent api
34+
// configure the options using the Fluent API
3735
parser.Configure(options => options.Port)
3836
.Name("p", "port")
3937
.Description("The port of the server")
4038
.Required();
4139

4240
// parse
43-
var result = parser.Parse(args);
41+
var parsed = parser.Parse(args);
4442

4543
// check for parsing errors
46-
if (result.HasErrors)
44+
if (parsed.HasErrors)
4745
{
4846
Console.ReadKey();
4947

5048
return -1;
5149
}
5250

53-
Console.WriteLine($"Parsed port is {result.Result.Port}");
51+
Console.WriteLine($"Parsed port is {parsed.Result.Port}");
5452
}
53+
54+
private class ServerOptions
55+
{
56+
// options
57+
public int Port { get; set; }
58+
}
59+
5560
```
5661

5762
Run command line

SampleApp/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static int Main(string[] args)
1414
// setup
1515
parser.Configure(opt => opt.MyInt)
1616
.Name("i", "int")
17-
.Description("Description for -s option, needs a string.")
17+
.Description("Description for -i option, needs an integer.")
1818
.Required();
1919

2020
parser.Configure(opt => opt.MyString)
@@ -24,12 +24,12 @@ static int Main(string[] args)
2424

2525
parser.Configure(opt => opt.MyBool)
2626
.Name("b", "bool")
27-
.Description("Description for -s option, needs a string.")
27+
.Description("Description for -b option, needs a boolean.")
2828
.Required();
2929

3030
parser.Configure(opt => opt.MyDouble)
3131
.Name("d", "double")
32-
.Description("Description for -s option, needs a string.")
32+
.Description("Description for -d option, needs a double.")
3333
.Required();
3434

3535
var startCmd = parser.AddCommand<CommandOptions>()
@@ -39,8 +39,8 @@ static int Main(string[] args)
3939
.OnExecuting((opt, parsedCmdOption) => Console.WriteLine($"Starting server using verbose option: {parsedCmdOption.Verbose}"));
4040

4141
startCmd.Configure(cmd => cmd.Verbose) // configures the command options can also be done using attributes
42-
.Required()
4342
.Description("Verbose output [true/false]")
43+
.Default(false)
4444
.Name("v", "verbose");
4545

4646
var result = parser.Parse(args);
@@ -70,7 +70,7 @@ static int Main(string[] args)
7070

7171
private static void HandleException(Exception exception)
7272
{
73-
// Do something with the exception..
73+
Console.WriteLine(exception.Message);
7474
}
7575

7676
private class Options

0 commit comments

Comments
 (0)