Open Davis-A opened 4 years ago
A reasonable workaround until this bug is fixed:
die "The --foo, --bar and --baz options are mutually exclusive.\n" . $usage->text
if 1 < grep defined($opt->$_), qw(foo bar baz);
die "You must give exactly one of the --foo, --bar and --baz options.\n" . $usage->text
unless 1 == grep defined($opt->$_), qw(foo bar baz);
@bpj I think you may have dropped these: ,,
In all seriousness, it really looks better with the oxford comma:
die "The --foo, --bar, and --baz options are mutually exclusive.\n" . $usage->text
if 1 < grep defined($opt->$_), qw(foo bar baz);
die "You must give exactly one of the --foo, --bar, and --baz options.\n" . $usage->text
unless 1 == grep defined($opt->$_), qw(foo bar baz);
@szr8 I guess I have some gut reaction against separating options with anything but space! 😃 The string has to be adapted to the needs/whims of the program/programmer anyway. The code works.
I just stumbled over the same issue which seems to come from having a dash in the option name.
Exclusive one of options are not throwing an error in some combinations.
Code below:
Example running and output:
Individually they show the correct behavior, set the $opt->mode.
But when combined in this case the top option
--ten-minute
never conflicts with the next two.