question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it possible to create options sections

See original GitHub issue

Hi, I was wondering if there’s plans to enable options sections in help output like we can see in https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options

WHISPER (EXPERIMENTAL) OPTIONS:
  --shh                       Enable Whisper
  --shh.maxmessagesize value  Max message size accepted (default: 1048576)
  --shh.pow value             Minimum POW accepted (default: 0.2)
  
DEPRECATED OPTIONS:
  --fast   Enable fast syncing through state downloads (replaced by --syncmode)
  --light  Enable light client mode (replaced by --syncmode)
  
MISC OPTIONS:
  --help, -h  show help

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 :

@Command(sections = {
    new Section("sec0","@|uppercase My first section|@",
    new Section("sec1","@|uppercase My second section|@",
    new Section("sec2","@|uppercase My third section|@"
}

then @Option(section = "sec0" ... )

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
remkopcommented, Feb 13, 2019

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:

Usage: <main class> [[-a=<a> -b=<b> -c=<c>] | (-x=<x> | -y=<y>)] [-BCEF]
                    [-A=<A>] [-D=<D>]
  -A=<A>
  -B
  -C
Co-occurring options:
These options must appear together, or not at all.
  -a=<a>
  -b=<b>
  -c=<c>
Exclusive options:
  -x=<x>
  -y=<y>
Remaining options:
  -D=<D>
  -E
  -F

Please try this out and provide feedback.

TODO:

  • internationalization: getting headers from resource bundle
  • documentation
0reactions
remkopcommented, Mar 30, 2019

Picocli 4.0.0-alpha-1 has been released which includes support for option sections in the usage help. See https://picocli.info/#_argument_groups for details.

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create Form Sections and Logic in Google Forms
To create a section in your form, click the bottom button in the floating right panel. Add a form section in Google Forms....
Read more >
Insert a section break - Microsoft Support
Add a section break. Select where you want a new section to begin. Go to Layout > Breaks. The types of section breaks...
Read more >
Use section breaks to layout or format a document
You can use section breaks to change the layout or formatting of pages in your document. ... Set up the formatting change just...
Read more >
Create an in-cell dropdown list - Computer - Google Support
On the Data validation rules panel, under "Criteria," select an option: Dropdown from a range: Choose the cells to include in the list....
Read more >
Organize your sidebar with custom sections - Slack
Tip: Click the or arrow icons to collapse or expand individual sections. Press Option (Mac) or Alt (Windows/Linux) and click any custom section...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found