nemec / clipr

Command Line Interface ParseR for .Net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support optional value when named argument is provided.

nemec opened this issue · comments

commented

When a property has a reference or nullable type, it should be possible for the user to specify that the value is optional (zero or one arguments) without turning that property into a list.

This way you could have an option that enables a server on a given port:

class Options
{
    [NamedArgument('s', "server", Constraint=NumArgsConstraint.Optional)]
    public int Server { get; set; }
}

--server  // default port
--server 1234  // set port

With a constraint like that, we should verify that NumArgs wasn't explicitly set too.