Mixing Required + Non-Required Options in an ArgGroup -- required options not validated
See original GitHub issueI have a use case similar to other issues – options with sub-options. For example:
cli --group=alpha --opt1=1 --group=bravo --opt2=foo
I’m trying something like this:
class Group {
@Option(names = {"--group"}, required = true) String name;
@Option(names = {"--opt1"}) int opt1;
@Option(names = {"--opt2"}) String opt2;
}
@ArgGroup(exclusive = false, multiplicity = "0..*") List<Group> groups;
This almost works:
cli --group=alpha --opt1=1 --group=bravo --opt2=foo
results ingroups = [{name=alpha, opt1=1}, {name=bravo, opt2=foo}]
cli --opt1=1 --group=alpha --opt2=foo
(weird that --opt1 comes before --group, but allowed) results ingroups = [{name=alpha, opt1=1, opt2=foo}]
However, calling cli --opt1=1
results in [{name=null, opt1=2}]
, with no error. I’d expect an error since the group name is required but not provided, but that doesn’t seem to be the case. Is this supported?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
picocli - a mighty tiny command line interface
Mixing Options and Positional Parameters. From picocli 2.0, positional parameters can be specified anywhere on the command line, they no longer need to...
Read more >Using Picocli, how do I require a positional argument and then ...
How do I handle that? I tried the following, but I get an error: ArgGroup has no options or positional parameters, and no...
Read more >clap - Rust - Docs.rs
Used to set all the options and relationships that define a valid argument for the program. ArgGroup. ArgGroup s are a family of...
Read more >Device Parameter Validation Request - IBM
HCD validates the following definitions: The parameter is supported for the device type; Required parameters are specified; The type of private parameter value ......
Read more >Quickstart - webargs 8.2.0 documentation
from webargs import fields, validate user_args = { # Required arguments "username": ... raise ValidationError("User does not exist") args = {"id": fields.
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
I have been able to reproduce the issue and found the cause: a bug in the validation logic.
@wjohnson5 Thanks for that background. A feature like this (“repeatable subcommands” https://github.com/remkop/picocli/issues/454 ) is on the TODO list but has been shelved until a clear use case comes up. On the surface it does not look that hard to implement but I haven’t spent the time to analyse in depth. The Click documentation is certainly helpful.