-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
Milestone
Description
I came across the following issue when using picocli 4.0.0-beta-2:
package test;
import java.util.List;
import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
public class ArgGroupsTest {
public static void main(String[] args) {
CommandLine cmd = new CommandLine(new TestCommand());
cmd.execute( "-g=2", "-g=3" );
}
@Command(name = "ArgGroupsTest")
static class TestCommand implements Runnable {
@ArgGroup( exclusive = false, multiplicity = "2")
List<DataSource> datasource;
static class DataSource {
@Option(names = "-g", required = true, defaultValue = "e")
static String aString;
}
@Override
public void run() {
// nothing to do here
}
}
}
Executing the minimum working example above, I'm getting an error (which is incorrect IMHO):
Error: Group: ([-g=<aString>]) ([-g=<aString>]) must be specified 2 times but was matched 1 times
Usage: ArgGroupsTest ([-g=<aString>]) ([-g=<aString>])
-g=<aString>
As soon as I'm removing defaultValue = "e"
from the annotation of the option aString, the program doesn't raise any error and exits normally.
If I'm removing both required = true
and defaultValue = "e"
from the annotation of the option aString, the erroneous error message shows up again.
Is this the intended behaviour?