-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixing Required + Non-Required Options in an ArgGroup -- required options not validated #870
Comments
Thank you for raising this. That does look odd. I will take a look when I get to my PC. |
Sorry, should have mentioned I'm using 4.0.4. |
Also, to give some context, I'm trying to build a Java equivalent of a CLI previously implemented in python via Click. It uses command chaining and the command group callback feature to accomplish repeated subcommands. AFAICT, repeated subcommands aren't possible in picocli, but this seems like the closest approach. |
@wjohnson5 Thanks for that background. A feature like this ("repeatable subcommands" #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. |
I have been able to reproduce the issue and found the cause: a bug in the validation logic. |
…red and non-required options in an ArgGroup
Fixed in master. Can you confirm?
Then test your project with picocli-4.0.5-SNAPSHOT. You should get an error for input like |
Confirmed fixed!
Thanks for the awesome support! I really appreciate the quick responses and turn around time. (I even searched for an option to donate some amount in appreciation -- if you're open to the idea of donations!) |
Thanks for confirming the fix and thanks for the kind words! Thanks also for letting me know about the other issues. Would it be possible to raise separate tickets for them? That makes it easier for me to track. |
Will do. :) |
I 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:
This almost works:
cli --group=alpha --opt1=1 --group=bravo --opt2=foo
results in
groups = [{name=alpha, opt1=1}, {name=bravo, opt2=foo}]
cli --opt1=1 --group=alpha --opt2=foo
(weird that --opt1 comes before --group, but allowed)results in
groups = [{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?The text was updated successfully, but these errors were encountered: