You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the Boolean argument is used repeatedly on the command line (i.e., more than once), its effective Boolean value flips with every repetition:
$ mytool -- dryRun is false
$ mytool -y -- dryRun is true
$ mytool -y -y -- dryRun is false
$ mytool -y -y -y -- dryRun is true
... and so on
While the first two lines work as expected, starting from the third line (where -y occurs twice), the effective value of dryRun flips with every repetition of -y. This is independent of whether the argument is repeated in direct succession (as is done in the example) or whether other arguments occur in-between repetitions.
Expected Behavior
As an immediate remedy, jCommand should consider arguments to be non-repeatable by default and thus reject repeated use of the same argument by throwing an exception when parsing the command line.
Looking at the problem more generally, it occurs to me that the @Parameter annotation of jCommand needs to be extended with a Boolean parameter, let's call it repeatable, that allows to specify whether an argument can occur repeatedly on the command line. The default of that parameter should be false (i.e. it may not be repeated).
The text was updated successfully, but these errors were encountered:
Consider the following argument definition:
Current Behavior
If the Boolean argument is used repeatedly on the command line (i.e., more than once), its effective Boolean value flips with every repetition:
While the first two lines work as expected, starting from the third line (where
-y
occurs twice), the effective value ofdryRun
flips with every repetition of-y
. This is independent of whether the argument is repeated in direct succession (as is done in the example) or whether other arguments occur in-between repetitions.Expected Behavior
As an immediate remedy, jCommand should consider arguments to be non-repeatable by default and thus reject repeated use of the same argument by throwing an exception when parsing the command line.
Looking at the problem more generally, it occurs to me that the
@Parameter
annotation of jCommand needs to be extended with a Boolean parameter, let's call itrepeatable
, that allows to specify whether an argument can occur repeatedly on the command line. The default of that parameter should befalse
(i.e. it may not be repeated).The text was updated successfully, but these errors were encountered: