Skip to content

Usage attribute #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion demo/ReadText.Demo.VB/Options.vb
Original file line number Diff line number Diff line change
@@ -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.")>
Expand All @@ -27,6 +28,16 @@ Public Class HeadOptions

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.")>
Expand Down
14 changes: 14 additions & 0 deletions demo/ReadText.Demo/Options.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using CommandLine;
using CommandLine.Text;
using System.Collections.Generic;

namespace ReadText.Demo
{
Expand Down Expand Up @@ -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<Example> 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.")]
Expand Down