Issue by sameerkattel
_Friday Oct 21, 2016 at 06:33 GMT_
_Originally opened as https://github.com/gsscoder/commandline/issues/364_
[Option('a', Required = false)]
public int a { get; set; }
[Option('b', Required = false)]
public int b { get; set; }
But either a or b should be required.
Comment by skalinkin
_Friday Nov 04, 2016 at 14:05 GMT_
Use Mutually Exclusive Options
https://github.com/gsscoder/commandline/wiki/Mutually-Exclusive-Options
[Option('a', MutuallyExclusiveSet = "ab")]
public int a { get; set; }
[Option('b', MutuallyExclusiveSet = "ab"]
public int b { get; set; }
Comment by nemec
_Saturday Nov 05, 2016 at 06:48 GMT_
@skalinkin Mutually Exclusive sets don't quite work that way. It means you cannot mix options with different "set names" in the same command line. If you made one set "a" and one "b" you couldn't use both at the same time.
@sameerkattel there is no feature matching those requirements in this library today.
Comment by tpluscode
_Thursday Jan 12, 2017 at 12:15 GMT_
Would it be sensible to assume that a set of required, mutually exclusive parameters means that exactly one of them must be provided? Like below, where I'd like to accept either -c or -n. Not both. Not none
``` c#
public class Options
{
[Option('c', Required = true, SetName = "connection")]
public string ConnectionString { get; set; }
[Option('n', Required = true, SetName = "connection")]
public string ConnectionStringName { get; set; }
}
```
Comment by tpluscode
_Thursday Jan 12, 2017 at 12:15 GMT_Would it be sensible to assume that a set of required, mutually exclusive parameters means that exactly one of them must be provided? Like below, where I'd like to accept either -c or -n. Not both. Not none
public class Options { [Option('c', Required = true, SetName = "connection")] public string ConnectionString { get; set; } [Option('n', Required = true, SetName = "connection")] public string ConnectionStringName { get; set; } }
The SetName values would have to be different, but in this example both are "connection". It should be something closer to the following:
public class Options
{
[Option('c', Required = true, SetName = "connection")]
public string ConnectionString { get; set; }
[Option('n', Required = true, SetName = "connectionName")]
public string ConnectionStringName { get; set; }
}
Further, the help-menu will list that both "-c" and "-n" are required to be used, when in reality it is required that exactly one (no more, no less) be used. If there is a way to change this (to control if the help-menu lists "requried" next to a option) please anyone let me know.
Most helpful comment
_Thursday Jan 12, 2017 at 12:15 GMT_
Would it be sensible to assume that a set of required, mutually exclusive parameters means that exactly one of them must be provided? Like below, where I'd like to accept either -c or -n. Not both. Not none
``` c#
public class Options
{
[Option('c', Required = true, SetName = "connection")]
public string ConnectionString { get; set; }
}
```