diff --git a/demo/ReadText.Demo.VB/Options.vb b/demo/ReadText.Demo.VB/Options.vb index 6e5b737a..eb87238f 100644 --- a/demo/ReadText.Demo.VB/Options.vb +++ b/demo/ReadText.Demo.VB/Options.vb @@ -1,8 +1,9 @@ Imports CommandLine +Imports CommandLine.Text Public Interface IOptions - <[Option]("n"c, "lines", SetName:="bylines", [Default]:=5UI, HelpText:="CPU source file to read.")> + <[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.")> @@ -27,6 +28,16 @@ Public Class HeadOptions Public Property FileName As String Implements IOptions.FileName + + 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.")> diff --git a/demo/ReadText.Demo/Options.cs b/demo/ReadText.Demo/Options.cs index e4b0d2ca..99f97208 100644 --- a/demo/ReadText.Demo/Options.cs +++ b/demo/ReadText.Demo/Options.cs @@ -1,4 +1,6 @@ using CommandLine; +using CommandLine.Text; +using System.Collections.Generic; namespace ReadText.Demo { @@ -35,6 +37,18 @@ class HeadOptions : IOptions public bool Quiet { get; set; } public string FileName { get; set; } + + [Usage(ApplicationAlias = "ReadText.Demo.exe")] + public static IEnumerable Examples + { + get + { + yield return new Example("normal scenario", new HeadOptions { FileName = "file.bin"}); + yield return new Example("specify bytes", new HeadOptions { FileName = "file.bin", Bytes=100 }); + yield return new Example("supress summary", UnParserSettings.WithGroupSwitchesOnly(), new HeadOptions { FileName = "file.bin", Quiet = true }); + yield return new Example("read more lines", new[] { UnParserSettings.WithGroupSwitchesOnly(), UnParserSettings.WithUseEqualTokenOnly() }, new HeadOptions { FileName = "file.bin", Lines = 10 }); + } + } } [Verb("tail", HelpText = "Displays last lines of a file.")]