Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

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

Example

Code

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;
    }
}

Definition

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();

Execution

> example.exe foo --foo=foo bar --bar "bar" qux 3

Foo=foo
Bar=bar
Qux=3

Help

> 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).
Clone this wiki locally