@@ -53,36 +53,36 @@ The project is and well suited to be included in your application. If you don't
53
53
Create a class to receive parsed values:
54
54
55
55
``` csharp
56
- class Options {
57
- [Option ('r' , " read" , Required = true ,
58
- HelpText = " Input file to be processed." )]
59
- public string InputFile { get ; set ; }
56
+ class Options {
57
+ [Option ('r' , " read" , Required = true ,
58
+ HelpText = " Input file to be processed." )]
59
+ public string InputFile { get ; set ; }
60
60
61
- [Option ('v' , " verbose" , DefaultValue = true ,
62
- HelpText = " Prints all messages to standard output." )]
63
- public bool Verbose { get ; set ; }
64
-
65
- [ParserState ]
66
- public IParserState LastParserState { get ; set ; }
67
-
68
- [HelpOption ]
69
- public string GetUsage () {
70
- return HelpText .AutoBuild (this ,
71
- (HelpText current ) => HelpText .DefaultParsingErrorsHandler (this , current ));
72
- }
73
- }
61
+ [Option ('v' , " verbose" , DefaultValue = true ,
62
+ HelpText = " Prints all messages to standard output." )]
63
+ public bool Verbose { get ; set ; }
64
+
65
+ [ParserState ]
66
+ public IParserState LastParserState { get ; set ; }
67
+
68
+ [HelpOption ]
69
+ public string GetUsage () {
70
+ return HelpText .AutoBuild (this ,
71
+ (HelpText current ) => HelpText .DefaultParsingErrorsHandler (this , current ));
72
+ }
73
+ }
74
74
```
75
75
76
76
Add few lines to your Main method:
77
77
78
78
``` csharp
79
- static void Main (string [] args ) {
80
- var options = new Options ();
81
- if (CommandLine .Parser .Default .ParseArguments (args , options )) {
82
- // Consume values here
83
- if (options .Verbose ) Console .WriteLine (" Filename: {0}" , options .InputFile );
84
- }
85
- }
79
+ static void Main (string [] args ) {
80
+ var options = new Options ();
81
+ if (CommandLine .Parser .Default .ParseArguments (args , options )) {
82
+ // Consume values here
83
+ if (options .Verbose ) Console .WriteLine (" Filename: {0}" , options .InputFile );
84
+ }
85
+ }
86
86
```
87
87
88
88
Acknowledgements:
0 commit comments