BadScript 2
Loading...
Searching...
No Matches
Options.cs
Go to the documentation of this file.
1using CommandLine;
3using System.Collections.Generic;
4
5namespace ReadText.Demo
6{
7 interface IOptions
8 {
9 [Option('n', "lines",
10 Default = 5U,
11 SetName = "bylines",
12 HelpText = "Lines to be printed from the beginning or end of the file.")]
13 uint? Lines { get; set; }
14
15 [Option('c', "bytes",
16 SetName = "bybytes",
17 HelpText = "Bytes to be printed from the beginning or end of the file.")]
18 uint? Bytes { get; set; }
19
20 [Option('q', "quiet",
21 HelpText = "Suppresses summary messages.")]
22 bool Quiet { get; set; }
23
24 [Value(0, MetaName = "input file",
25 HelpText = "Input file to be processed.",
26 Required = true)]
27 string FileName { get; set; }
28 }
29
30 [Verb("head", true, HelpText = "Displays first lines of a file.")]
32 {
33 public uint? Lines { get; set; }
34
35 public uint? Bytes { get; set; }
36
37 public bool Quiet { get; set; }
38
39 public string FileName { get; set; }
40
41 [Usage(ApplicationAlias = "ReadText.Demo.exe")]
42 public static IEnumerable<Example> Examples
43 {
44 get
45 {
46 yield return new Example("normal scenario", new HeadOptions { FileName = "file.bin"});
47 yield return new Example("specify bytes", new HeadOptions { FileName = "file.bin", Bytes=100 });
48 yield return new Example("suppress summary", UnParserSettings.WithGroupSwitchesOnly(), new HeadOptions { FileName = "file.bin", Quiet = true });
49 yield return new Example("read more lines", new[] { UnParserSettings.WithGroupSwitchesOnly(), UnParserSettings.WithUseEqualTokenOnly() }, new HeadOptions { FileName = "file.bin", Lines = 10 });
50 }
51 }
52 }
53
54 [Verb("tail", HelpText = "Displays last lines of a file.")]
56 {
57 public uint? Lines { get; set; }
58
59 public uint? Bytes { get; set; }
60
61 public bool Quiet { get; set; }
62
63 public string FileName { get; set; }
64 }
65}
Models a command line usage example.
Definition Example.cs:13
Provides settings for when formatting command line from an options instance../>.
static UnParserSettings WithGroupSwitchesOnly()
Factory method that creates an instance of CommandLine.UnParserSettings with GroupSwitches set to tru...
static UnParserSettings WithUseEqualTokenOnly()
Factory method that creates an instance of CommandLine.UnParserSettings with UseEqualToken set to tru...
static IEnumerable< Example > Examples
Definition Options.cs:43