forked from gsscoder/commandline
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOptions.vb
54 lines (37 loc) · 2.13 KB
/
Options.vb
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
Imports CommandLine
Imports CommandLine.Text
Public Interface IOptions
<[Option]("n"c, "lines", SetName:="bylines", [Default]:=5UI, HelpText:="Lines to be printed from the beginning or end of the file.")>
Property Lines As UInteger?
<[Option]("c"c, "bytes", SetName:="bybytes", HelpText:="Bytes to be printed from the beginning or end of the file.")>
Property Bytes As UInteger?
<[Option]("q"c, "quiet", HelpText:="Supresses summary messages.")>
Property Quiet As Boolean
<[Value](0, MetaName:="input file", Required:=True, HelpText:="Input file to be processed.")>
Property FileName As String
End Interface
<[Verb]("head", HelpText:="Displays first lines of a file.")>
Public Class HeadOptions
Implements IOptions
Public Property Lines As UInteger? Implements IOptions.Lines
Public Property Bytes As UInteger? Implements IOptions.Bytes
Public Property Quiet As Boolean Implements IOptions.Quiet
Public Property FileName As String Implements IOptions.FileName
<Usage(ApplicationAlias:="ReadText.Demo.VB.exe")>
Public Shared ReadOnly Iterator Property IEnumerable() As IEnumerable(Of Example)
Get
Yield New Example("normal scenario", New HeadOptions With {.FileName = "file.bin"})
Yield New Example("specify bytes", New HeadOptions With {.FileName = "file.bin", .Bytes = 100})
Yield New Example("supress summary", UnParserSettings.WithGroupSwitchesOnly(), New HeadOptions With {.FileName = "file.bin", .Quiet = True})
Yield New Example("read more lines", New UnParserSettings() {UnParserSettings.WithGroupSwitchesOnly(), UnParserSettings.WithUseEqualTokenOnly()}, New HeadOptions With {.FileName = "file.bin", .Lines = 10})
End Get
End Property
End Class
<[Verb]("tail", HelpText:="Displays last lines of a file.")>
Public Class TailOptions
Implements IOptions
Public Property Lines As UInteger? Implements IOptions.Lines
Public Property Bytes As UInteger? Implements IOptions.Bytes
Public Property Quiet As Boolean Implements IOptions.Quiet
Public Property FileName As String Implements IOptions.FileName
End Class