-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathProgram.cs
51 lines (41 loc) · 1.08 KB
/
Program.cs
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
using Cocona;
namespace CoconaSample.InAction.CommandOptions;
class Program
{
static void Main(string[] args)
{
CoconaApp.Run<Program>(args);
}
public void Number(int foo)
{
Console.WriteLine(foo);
}
public void Enum(User user)
{
Console.WriteLine(user);
}
public enum User
{
Alice, Karen, Other
}
// dotnet run -- booleantruebydefault --dryRun=false
public void BooleanTrueByDefault(bool dryRun = true)
{
Console.WriteLine($"DryRun: {dryRun}");
}
// dotnet run -- array -I../path/to/foo -I../foo/bar/baz
public void Array([Option('I')]string[] include)
{
foreach (var item in include)
{
Console.WriteLine(item);
}
}
public void HiddenOptionInHelp(bool visible, [Hidden]bool hidden)
{
Console.WriteLine($"Visible={visible}; Hidden={hidden}");
}
public void HasDescription([Option(Description = "Description of the option")] int value, [Argument(Description = "Description of the argument")]string arg)
{
}
}