Skip to content

Commit dd07605

Browse files
author
Ethan Lindemann-Michael
committed
Updated C# quick start example to work with the newer API.
1 parent 9cb0e30 commit dd07605

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

README.md

+15-18
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,28 @@ See more details in the [wiki for direct integrations](https://github.com/gsscod
5454
C# Examples:
5555

5656
```csharp
57-
internal class Options {
58-
[Option('r',"read",
59-
Required = true,
60-
HelpText = "Input files to be processed.")]
57+
class Options
58+
{
59+
[Option('r', "read", Required = true, HelpText = "Input files to be processed.")]
6160
public IEnumerable<string> InputFiles { get; set; }
6261

6362
// Omitting long name, defaults to name of property, ie "--verbose"
64-
[Option(
65-
DefaultValue = false,
66-
HelpText = "Prints all messages to standard output.")]
63+
[Option(Default = false, HelpText = "Prints all messages to standard output.")]
6764
public bool Verbose { get; set; }
68-
69-
[Option("stdin",
70-
DefaultValue = false
71-
HelpText = "Read from stdin")]
72-
public bool stdin { get; set; }
73-
74-
[Value(0, MetaName = "offset",
75-
HelpText = "File offset.")]
65+
66+
[Option("stdin", Default = false, HelpText = "Read from stdin")]
67+
public bool stdin { get; set; }
68+
69+
[Value(0, MetaName = "offset", HelpText = "File offset.")]
7670
public long? Offset { get; set; }
7771
}
7872

79-
static int Main(string[] args) {
80-
var options = new Options();
81-
var isValid = CommandLine.Parser.Default.ParseArgumentsStrict(args, options);
73+
static void Main(string[] args)
74+
{
75+
CommandLine.Parser.Default.ParseArguments<Options>(args)
76+
.WithParsed<Options>(opts => RunOptionsAndReturnExitCode(opts))
77+
.WithNotParsed<Options>((errs) => HandleParseError(errs));
78+
}
8279
```
8380

8481
F# Examples:

0 commit comments

Comments
 (0)