@@ -54,31 +54,28 @@ See more details in the [wiki for direct integrations](https://github.com/gsscod
54
54
C# Examples:
55
55
56
56
``` 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." )]
61
60
public IEnumerable <string > InputFiles { get ; set ; }
62
61
63
62
// 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." )]
67
64
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." )]
76
70
public long ? Offset { get ; set ; }
77
71
}
78
72
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
+ }
82
79
```
83
80
84
81
F# Examples:
0 commit comments