This repository has been archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Specification
Patrik edited this page Nov 5, 2017
·
9 revisions
This specification does not describe the current state of the library, but where we want it to go.
- Example
- Code
- Definition
- Execution
- Help
public sealed class FooSettings
{
[Option("-f|--f [VALUE]")]
[Description("Sets the foo.")]
public string Foo { get;set; }
}
public sealed class BarSettings
{
[Option("-b|--bar <VALUE>")]
[TypeConverter(typeof(BarConverter))]
[Description("Resets the bar.")]
public string Bar { get;set; }
}
public sealed class QuxSettings
{
[Argument("<VALUE>")]
[DefaultValue(1)]
public int Qux { get;set; }
}
[Description("Quxxes the bar and foo")]
public sealed class QuxCommand : Command<QuxSettings>
{
public int Execute(BazSettings settings)
{
return 0;
}
}
var app = new CommandApp();
app.AddProxy<FooSettings>("foo", foo =>
{
foo.SetDescription("Executes the foo.")
foo.AddProxy<BarSettings>("bar", bar =>
{
bar.SetDescription("Performs the bar.")
bar.AddCommand<QuxCommand>("qux");
});
});
app.Run();
> example.exe foo --foo=foo bar --bar "bar" qux 3
Foo=foo
Bar=bar
Qux=3
> example.exe
Usage: example.exe [command]
Commands:
foo Executes the foo.
> example.exe foo --help
Usage: example.exe foo [options] [command]
Options:
-f|--foo [VALUE] Sets the foo.
Commands:
bar Performs the bar
> example.exe foo bar --help
Usage: example.exe foo bar [options] [command]
Options:
-b|--bar <VALUE> Resets the bar (required).
Commands:
qux Quxxes the bar and foo
> example.exe foo bar qux --help
Usage: example.exe foo bar qux <QUX>
Arguments:
<QUX> Quxxes the bar and foo (required).