forked from commandlineparser/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptions.cs
69 lines (56 loc) · 2.38 KB
/
Options.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using CommandLine;
using CommandLine.Text;
using System.Collections.Generic;
namespace ReadText.LocalizedDemo
{
interface IOptions
{
[Option('n', "lines",
Default = 5U,
SetName = "bylines",
HelpText = "HelpTextLines",
ResourceType = typeof(Properties.Resources))]
uint? Lines { get; set; }
[Option('c', "bytes",
SetName = "bybytes",
HelpText = "HelpTextBytes",
ResourceType = typeof(Properties.Resources))]
uint? Bytes { get; set; }
[Option('q', "quiet",
HelpText = "HelpTextQuiet",
ResourceType = typeof(Properties.Resources))]
bool Quiet { get; set; }
[Value(0, MetaName = "input file",
HelpText = "HelpTextFileName",
Required = true,
ResourceType = typeof(Properties.Resources))]
string FileName { get; set; }
}
[Verb("head", HelpText = "HelpTextVerbHead", ResourceType = typeof(Properties.Resources))]
class HeadOptions : IOptions
{
public uint? Lines { get; set; }
public uint? Bytes { get; set; }
public bool Quiet { get; set; }
public string FileName { get; set; }
[Usage(ApplicationAlias = "ReadText.LocalizedDemo.exe")]
public static IEnumerable<Example> Examples
{
get
{
yield return new Example(Properties.Resources.ExamplesNormalScenario, new HeadOptions { FileName = "file.bin"});
yield return new Example(Properties.Resources.ExamplesSpecifyBytes, new HeadOptions { FileName = "file.bin", Bytes=100 });
yield return new Example(Properties.Resources.ExamplesSuppressSummary, UnParserSettings.WithGroupSwitchesOnly(), new HeadOptions { FileName = "file.bin", Quiet = true });
yield return new Example(Properties.Resources.ExamplesReadMoreLines, new[] { UnParserSettings.WithGroupSwitchesOnly(), UnParserSettings.WithUseEqualTokenOnly() }, new HeadOptions { FileName = "file.bin", Lines = 10 });
}
}
}
[Verb("tail", HelpText = "HelpTextVerbTail", ResourceType = typeof(Properties.Resources))]
class TailOptions : IOptions
{
public uint? Lines { get; set; }
public uint? Bytes { get; set; }
public bool Quiet { get; set; }
public string FileName { get; set; }
}
}