Skip to content

Commit 615f866

Browse files
authored
Merge pull request #1 from gsscoder/master
rebase
2 parents 806d2d2 + caf0ca3 commit 615f866

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

demo/ReadText.Demo.VB/Options.vb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Imports CommandLine
2+
Imports CommandLine.Text
23

34
Public Interface IOptions
45

5-
<[Option]("n"c, "lines", SetName:="bylines", [Default]:=5UI, HelpText:="CPU source file to read.")>
6+
<[Option]("n"c, "lines", SetName:="bylines", [Default]:=5UI, HelpText:="Lines to be printed from the beginning or end of the file.")>
67
Property Lines As UInteger?
78

89
<[Option]("c"c, "bytes", SetName:="bybytes", HelpText:="Bytes to be printed from the beginning or end of the file.")>
@@ -27,6 +28,16 @@ Public Class HeadOptions
2728

2829
Public Property FileName As String Implements IOptions.FileName
2930

31+
<Usage(ApplicationAlias:="ReadText.Demo.VB.exe")>
32+
Public Shared ReadOnly Iterator Property IEnumerable() As IEnumerable(Of Example)
33+
Get
34+
Yield New Example("normal scenario", New HeadOptions With {.FileName = "file.bin"})
35+
Yield New Example("specify bytes", New HeadOptions With {.FileName = "file.bin", .Bytes = 100})
36+
Yield New Example("supress summary", UnParserSettings.WithGroupSwitchesOnly(), New HeadOptions With {.FileName = "file.bin", .Quiet = True})
37+
Yield New Example("read more lines", New UnParserSettings() {UnParserSettings.WithGroupSwitchesOnly(), UnParserSettings.WithUseEqualTokenOnly()}, New HeadOptions With {.FileName = "file.bin", .Lines = 10})
38+
End Get
39+
End Property
40+
3041
End Class
3142

3243
<[Verb]("tail", HelpText:="Displays last lines of a file.")>

demo/ReadText.Demo/Options.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using CommandLine;
2+
using CommandLine.Text;
3+
using System.Collections.Generic;
24

35
namespace ReadText.Demo
46
{
@@ -35,6 +37,18 @@ class HeadOptions : IOptions
3537
public bool Quiet { get; set; }
3638

3739
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("supress 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+
}
3852
}
3953

4054
[Verb("tail", HelpText = "Displays last lines of a file.")]

0 commit comments

Comments
 (0)