File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,43 @@ You can utilize the parser library in several ways:
46461 . Create a class to define valid options, and to receive the parsed options.
47472 . Call ParseArguments with the args string array.
4848
49+ C# Quick Start:
50+
51+ ``` csharp
52+ using System ;
53+ using CommandLine ;
54+
55+ namespace QuickStart
56+ {
57+ class Program
58+ {
59+ public class Options
60+ {
61+ [Option ('v' , " verbose" , Required = false , HelpText = " Set output to verbose messages." )]
62+ public bool Verbose { get ; set ; }
63+ }
64+
65+ static void Main (string [] args )
66+ {
67+ Parser .Default .ParseArguments <Options >(args )
68+ .WithParsed <Options >(o =>
69+ {
70+ if (o .Verbose )
71+ {
72+ Console .WriteLine ($" Verbose output enabled. Current Arguments: -v {o .Verbose }" );
73+ Console .WriteLine (" Quick Start Example! App is in Verbose mode!" );
74+ }
75+ else
76+ {
77+ Console .WriteLine ($" Current Arguments: -v {o .Verbose }" );
78+ Console .WriteLine (" Quick Start Example!" );
79+ }
80+ });
81+ }
82+ }
83+ }
84+ ```
85+
4986C# Examples:
5087
5188``` csharp
You can’t perform that action at this time.
0 commit comments