[Mono.Options] Add Mono.Options.Command, .CommandSet
authorJonathan Pryor <jonpryor@vt.edu>
Tue, 31 Jan 2017 20:27:32 +0000 (15:27 -0500)
committerMarek Safar <marek.safar@gmail.com>
Mon, 6 Mar 2017 22:37:55 +0000 (23:37 +0100)
commitc1b9fc566a365cf6923218eae9098d0fd0e632ae
tree68ccbf40f8f5d8ba6cf9457e4bb9d4e6cb656ddf
parent8c7b88f1aa37304927701b6f0d273706ea6707f6
[Mono.Options] Add Mono.Options.Command, .CommandSet

Mono.Options.CommandSet allows easily having separate commands and
associated command options, allowing creation of a *suite* along the
lines of **git**(1), **svn**(1), etc.

CommandSet allows intermixing plain text strings for `--help` output,
Option values -- as supported by OptionSet -- and Command instances,
which have a name, optional help text, and an optional OptionSet.

var suite = new CommandSet ("suite-name") {
// Use strings and option values, as with OptionSet
"usage: suite-name COMMAND [OPTIONS]+",
{ "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 },
// Commands may also be specified
new Command ("command-name", "command help") {
Options = new OptionSet {/*...*/},
Run     = args => { /*...*/},
},
new MyCommandSubclass (),
};
suite.Run (new string[]{...});

CommandSet provides a `help` command, and forwards `help COMMAND`
to the registered Command instance by invoking Command.Invoke()
with `--help` as an option.
14 files changed:
mcs/class/Mono.Options/Documentation/en/Mono.Options/Command.xml [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/Mono.Options/CommandSet.xml [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/Mono.Options/HelpCommand.xml [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/Mono.Options/OptionSet.xml
mcs/class/Mono.Options/Documentation/en/examples/commands.cs [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/examples/commands.in [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/examples/commands.txt [new file with mode: 0644]
mcs/class/Mono.Options/Documentation/en/index.xml
mcs/class/Mono.Options/Makefile
mcs/class/Mono.Options/Mono.Options/Options.cs
mcs/class/Mono.Options/Mono.Options_test.dll.sources
mcs/class/Mono.Options/Test/Mono.Options-Test-net_4_x.csproj [new file with mode: 0644]
mcs/class/Mono.Options/Test/Mono.Options/CommandSetTest.cs [new file with mode: 0644]
mcs/class/Mono.Options/Test/Mono.Options/CommandTest.cs [new file with mode: 0644]