-
Notifications
You must be signed in to change notification settings - Fork 440
Closed
Labels
Milestone
Description
I just started to try out the new 4.0.0 alpha build, the new argument group feature comes in very handy for me. I came across the following issue, though:
Minimal code sample:
public class ArgGroupsTest {
public static void main(String[] args) {
CommandLine cmd = new CommandLine(new TestCommand());
cmd.parseWithHandler(new CommandLine.RunAll(), args);
}
@Command(subcommands = { TestSubCommand.class, CommandLine.HelpCommand.class }, name = "ArgGroupsTest", mixinStandardHelpOptions = true, version = "0.xx")
static class TestCommand implements Runnable {
@ArgGroup(exclusive = true, multiplicity = "1")
DataSource datasource;
static class DataSource {
@Option(names = "-a", required = true)
static boolean isA;
@Option(names = "-b", required = true)
static File dataFile;
}
@Override
public void run() {
// nothing to do here
}
}
@Command(name = "test", showDefaultValues = true)
static class TestSubCommand implements Runnable {
@Override
public void run() {
System.out.println("Subcommand called!");
}
}
}
Now, when requesting help:
$ ArgGroupsTest --help
the following message is presented on stderr:
Error: Missing required argument (specify one of these): -a, -b=<dataFile>
Usage: ArgGroupsTest (-a | -b=<dataFile>) [-hV] [COMMAND]
-a
-b=<dataFile>
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
test
help Displays help information about the specified command
Once help is requested, usage instructions should be given on stdout, I don't expect any error due to a missing required mutually exclusive option here.