-
Notifications
You must be signed in to change notification settings - Fork 432
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
[Feature Request] Option dependencies #295
Comments
Ok, interesting! |
It would be great to also have some way of specifying option alternatives. Like in the below
(PS: @rempkop Thank you for making this great library. Its delicious !) |
Related: #199 will give support for mutually exclusive options. Currently I don’t think that ticket mentioned making a single option exclusive with a group of options. It may be good to make a note of this idea on the #199 ticket. What may be interesting for your use case is that picocli already allows you to specify a custom synopsis to show which options are mutually exclusive: http://picocli.info/#_custom_synopsis |
Thanks for the advice. I have added a note to the #199 ticket. For now, I will add a custom synopsis as you suggest. |
…options This mechanism is aimed at preventing the use of options if the associated service is disabled. This is not a generic system as our need is simple here. But in future version of PicoCLI some options dependency mechanism may be implemented that could replace this. See remkop/picocli#295 Our current mechanism apply to p2p, rpc (http+ws), mining, privacy and metrics. Also renamed inconsistent isRpcHttpEnabled option variable and moved --privacy-enabled option to be on top of other privacy options. Related tests where added or updated and renamed.
fixes NC-1737 by adding an option dependency mechanism for "enabled" options This mechanism is aimed at preventing the use of options if the associated service is disabled. This is not a generic system as our need is simple here. But in future version of PicoCLI some options dependency mechanism may be implemented that could replace this. See remkop/picocli#295 Our current mechanism apply to p2p, rpc (http+ws), mining, privacy and metrics. It logs a warning wherever some options are used that require another one to be enabled. Also renamed inconsistent isRpcHttpEnabled option variable and moved --privacy-enabled option to be on top of other privacy options. injects a Logger in PantheonCommand constructor to log and also provides injection capabilities for a mock in tests. adds unit tests updates tests logger name to TEST_LOGGER to prevent confusion with the mock remove --max-trailing-peers after merge with master where it was deleted updated rules for metrics
A first cut of support for
Example: @Command(argGroups = {
@ArgGroup(name = "EXCL", exclusive = true, required = true),
@ArgGroup(name = "ALL", exclusive = false, required = true),
@ArgGroup(name = "COMPOSITE", exclusive = false, required = false,
subgroups = {"ALL", "EXCL"}),
})
class App {
@Option(names = "-x", groups = "EXCL") boolean x;
@Option(names = "-y", groups = "EXCL") boolean y;
@Option(names = "-a", groups = "ALL") boolean a;
@Option(names = "-b", groups = "ALL") boolean b;
} This defines a composite group with the following synopsis:
The composite group consists of the required exclusive group Valid user input for this group would be:
Any other combination of Still TODO:
That said, the majority of the functionality is there. |
…295] options that must co-occur (dependent options)
Picocli 4.0.0-alpha-1 has been released which includes support for options that must co-occur (dependent options). Please try this and provide feedback. We can still make changes. What do you think of the annotations API? What about the programmatic API? Does it work as expected? Are the input validation error messages correct and clear? Is the documentation clear and complete? Anything you want to change or improve? Any other feedback? |
Would be nice to specify option dependencies i.e. if an option is present, another option must also be present.
Reference example ('requires' flag):
https://github.com/kbknapp/clap-rs/blob/master/examples/07_option_args.rs
https://docs.rs/clap/2.31.1/clap/struct.Arg.html#method.requires
Usage example:
Right now it's possible to check this after parsing is done, so it's not a pressing issue, but it would be nice to have.
The text was updated successfully, but these errors were encountered: