-
Notifications
You must be signed in to change notification settings - Fork 420
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
With a List<> Option in @ArgGroup, group incorrectly appears twice in the synopsis #1065
Comments
Thank you for raising this. |
The short storyThis was a bug. In the next version of picocli, the expected synopsis can be achieved by setting the argument group to The long storyThis synopsis stuff can get quite complex... Let's break it down. Option SynopsisBefore we go into argument groups, let's first look at simple options. Picocli shows a different synopsis for required and non-required options, and for single-value and multi-value options. The below table illustrates. Note especially the notation for required multi-value options. Such options must be specified at least once, but possibly multiple times, and the synopsis reflects this:
Argument Group SynopsisNow, let's look at groups. In Groups have a Now, let's put these together. The table below shows the synopsis for groups with two options,
Split Regex SynopsisThe final element: when the option accepts a Problem: synopsis too longWhen I execute your example with picocli 4.3.2, I get the following synopsis:
This is incorrect, and does not follow the specifications above. With picocli 4.3.3-SNAPSHOT, I get the correct synopsis:
Given the above, we now know why: this is the synopsis for a multi-value option on an exclusive group. The option became a Getting a shorter synopsisWith picocli 4.3.3, one idea is to make the group non-exclusive (after all, with only one option, exclusive or non-exclusive does not matter). The program is almost unchanged ( @Command(name = "MyApp")
public class App implements Runnable {
@ArgGroup(exclusive = false) // was: exclusive=true
MyGroup myGroup;
static class MyGroup {
@Option(names="-A", paramLabel="N", split=",")
List<Long> A;
}
// ...
} The synopsis of the usage help message now looks like this:
I hope this explains things. |
Apologies, I did some refactoring to reduce duplicate code and this appears to have changed the behavior. The expected synopsis can be achieved in the next release by making the group non-exclusive. |
I updated my answer above. |
Shows the following output:
Usage: MyApp [[-A=N[,N...]] [-A=N[,N...]]...]
Expected output:
Usage: MyApp [-A=N[,N...]]...
Issue initially raised on SO here.
The text was updated successfully, but these errors were encountered: