-
Notifications
You must be signed in to change notification settings - Fork 422
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
Make it possible to create options sections #450
Comments
Yes I like that idea very much. I did a spike for something similar in #199, but other work took priority. |
A bit of brainstorming. What if With multi sub-command cli tool, such Mixins could be printed as sections in a manpage. And, won't get repeated for each sub-command, because they would be shared option groups / sections. |
I think a separate annotation will be needed anyway for the section titles. |
Marking this as a duplicate of #199. That’ll be a major new feature of the 4.0 release. |
An initial implementation of this has been pushed to master. Example usage: @Command(argGroups = {
@ArgGroup(name = "ALL", exclusive = false, required = false, order = 10,
heading = "Co-occurring options:%nThese options must appear together, or not at all.%n"),
@ArgGroup(name = "EXCL", exclusive = true, required = true, order = 20,
heading = "Exclusive options:%n"),
@ArgGroup(name = "COMPOSITE", exclusive = true, required = false,
subgroups = {"ALL", "EXCL"}),
@ArgGroup(name = "INITIAL", validate = false, heading = "", order = 0),
@ArgGroup(name = "REMAINDER", validate = false, heading = "Remaining options:%n", order = 100)
})
class App {
@Option(names = "-x", groups = "EXCL") int x;
@Option(names = "-y", groups = "EXCL") int y;
@Option(names = "-a", groups = "ALL") int a;
@Option(names = "-b", groups = "ALL") int b;
@Option(names = "-c", groups = "ALL") int c;
@Option(names = "-A", groups = "INITIAL") int A;
@Option(names = "-B", groups = "INITIAL") boolean B;
@Option(names = "-C", groups = "INITIAL") boolean C;
@Option(names = "-D", groups = "REMAINDER") int D;
@Option(names = "-E", groups = "REMAINDER") boolean E;
@Option(names = "-F", groups = "REMAINDER") boolean F;
} This will generate the following usage help messsage:
Please try this out and provide feedback. TODO:
|
Picocli 4.0.0-alpha-1 has been released which includes support for option sections in the usage help. 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 have used @mixin (see https://picocli.info/apidocs/picocli/CommandLine.Mixin.html), but I think I ran into issues with remkop/picocli#450 (or a similar issue) where the mutually exclusive argument group was ignored when 'AcmeServerOption` was imported as a Mixin (vs directly using '@Arggroup(multiplicity = "1")' where it was used.
Hi,
I was wondering if there's plans to enable options sections in help output like we can see in https:/ethereum/go-ethereum/wiki/Command-Line-Options
By having something like an attribute in the
@Option
indicating a section id and map of sections id and sections titles in the@Command
. Then we would be able to group options (@Command.groupOptions
boolean attribute ?) by section.Sorting (
@Command.sortOptions
attribute) could also affect the order of appearance of that in the way that alphabetical would also sort section first and options in the section.Also a being able to use
@|
in sections title would be nice if we could also add an uppercase style :then
@Option(section = "sec0" ... )
The text was updated successfully, but these errors were encountered: