-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadme.txt
62 lines (47 loc) · 1.18 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Args - Small, simple command line argument parsing utility for .NET
Licensed under MIT license.
Sample usage:
class Program
{
static int Main(string[] args)
{
Args arguments = new Args("sample program that will echo an integer");
var numberArgument = arguments.Add<int>("n", "number", "some random number", true);
arguments.Parse(args);
if (!arguments.IsValid)
{
arguments.PrintUsage(System.Console.Error);
return 1;
}
int n = numberArgument.Value;
System.Console.WriteLine(n);
}
}
Results of valid arguments:
---------------------------
> SampleProgram.exe /n 3
3
> SampleProgram.exe -n 3
3
> SampleProgram.exe /number 3
3
> SampleProgram.exe -number 3
3
> SampleProgram.exe /n:3
3
> SampleProgram.exe -n:3
3
> SampleProgram.exe /number:3
3
> SampleProgram.exe -number:3
3
Results of invalid arguments:
-----------------------------
> SampleProgram.exe 3
SampleProgram - sample program that will echo an integer
usage: SampleProgram -n <int>
n, number - int; required. some random number
>SampleProgram.exe n foo
SampleProgram - sample program that will echo an integer
usage: SampleProgram -n <int>
n, number - int; required. some random number