Here's a minimal example to illustrate the problem:
import java.util.concurrent.Callable;
import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
@Command(name = "multiplicity")
class Multiplicity implements Callable<Integer> {
@ArgGroup(exclusive = false, multiplicity = "1")
private RequiredGroup requiredGroup;
static class RequiredGroup {
@Option(names = "--option_one")
private String optionOne;
@Option(names = "--option_two")
private String optionTwo;
}
@Override
public Integer call() throws Exception {
return 0;
}
public static void main(String... args) {
int exitCode = new CommandLine(new Multiplicity()).execute(args);
System.exit(exitCode);
}
}
With this example, I would expect that the command without any options (i.e. multiplicity), would throw a MissingParameterException. However, in the current version (4.7.4) the command executes and the call() method is executed. Note, that the requiredGroup object is null.
On a much older version of picocli (4.1.4), running this command works as expected. It throws a MissingParameterException with the text Error: Missing required argument(s):.
I am not sure exactly where the regression happened or if this is even a regression? From my reading of the docs, it does seem like one. In the ArgGroup documentation:
define a set of arguments that must co-occur. Set exclusive = false to define a group of options and positional parameters that must always be specified together. Picocli will throw a MissingParameterException if not all the options and positional parameters in a co-occurring group are specified together.
Groups may be optional (multiplicity = "0..1"), required (multiplicity = "1")
When the parent group is required, at least one subgroup must be present.
Here's a minimal example to illustrate the problem:
With this example, I would expect that the command without any options (i.e.
multiplicity), would throw a MissingParameterException. However, in the current version (4.7.4) the command executes and thecall()method is executed. Note, that therequiredGroupobject is null.On a much older version of picocli (4.1.4), running this command works as expected. It throws a MissingParameterException with the text
Error: Missing required argument(s):.I am not sure exactly where the regression happened or if this is even a regression? From my reading of the docs, it does seem like one. In the ArgGroup documentation: