CLI11 icon indicating copy to clipboard operation
CLI11 copied to clipboard

Group can exclude option, but not the reverse

Open BMBurstein opened this issue 3 years ago • 1 comments

As far as I can tell, exclude() is a symmetric operation, i.e. opt1->exclude(opt2); is the same as opt2->exclude(opt1);. With options this works well, since I can call exclude() on either of the options and pass the other as a parameter. But if I have an option and a group the are mutually exclusive, I can only do the call from the group side, i.e. grp1->exclude(opt1); works, but opt1->exclude(grp1); doesn't compile.

Maybe an overload should be added to allow this to work in both directions.

BMBurstein avatar Aug 10 '22 06:08 BMBurstein

I do not believe this would be possible or wise as it would require circular definitions.
The recommendation to achieve the same effect is to put opt1 in a second option_group and use

grp2->exclude(grp1)

phlptp avatar Aug 22 '22 14:08 phlptp

Going to close this as there is an intended means to achieve the same effect and adding this suggestion would add significant complexity to the option handing code.

phlptp avatar Dec 10 '22 15:12 phlptp