Long boolean options with arity 0 still allow parameters.
See original GitHub issueGiven a option definition:
@CommandLine.Option(names = {"--no-global-labels"}, arity = "0")
public void setNoGlobalLabels(final boolean noGlobalLabels) {}
This still allows --no-global-labels=false
.
For non-boolean long options arity = "0"
probably doesn’t make sense. But for options like this it’d be nice to have picocli enforce the arity rather than have to check the boolean parameter and throw an exception if its false
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
CommandLine.Option (picocli 4.7.0 API)
By default picocli allows boolean options (also called "flags" or "switches") to have an optional parameter, which must be either "true" or "false"...
Read more >JCommander
When a Parameter annotation is found on a field of type boolean or Boolean , JCommander interprets it as an option with an...
Read more >CliBuilder (groovy 2.5.8 API)
An option must have either a long name or a short name (or both). args, int or String, arity, args indicates the number...
Read more >Command-line syntax overview for System.CommandLine
Options that have no value specified are typically Boolean parameters that default to true if the option is specified on the command line....
Read more >CommandLine.Range (Apache Log4j Core 2.11.0 API)
Returns the default arity Range : for options this is 0 for booleans and 1 for other types, for parameters booleans have arity...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@remkop Thanks for the quick-fix. I can wait till 3.7 since I have interm a work-around (throw if value = false).
Fixed in master.
Is this a critical issue for you? (That is, do you need a 3.6.2 release for this, or can it wait a few weeks for the 3.7 release?)