nimrod93
nimrod93

Reputation: 1

Can an Option be set as Required depending on another's Option parsed value in CommandLineParser?

I would like to set an Option as "Required" if the value parsed from another Option is equal to a particular value. Is it possible to achieve that without having to post-process the parsed Options? Something like:

    [Option('f', "foo", Required = true, HelpText = "Name of process")]
    public string Foo{ get; set; }

    [Option('b', "bar", Required = ( Foo == "egg" ), HelpText = "Name of process")]
    public string Bar{ get; set; }

Upvotes: 0

Views: 596

Answers (1)

Krishna Bankar
Krishna Bankar

Reputation: 124

Try this [RequiredIf(method/attribute, value)] instead of [Option]

Upvotes: 1

Related Questions