I would like to group options in the help message but have one option in that group required. Actually, I want to have one subgroup of the help-message-group required, but I have trouble with both:
import java.util.concurrent.Callable;
import picocli.CommandLine;
@CommandLine.Command(mixinStandardHelpOptions = true, sortOptions = false)
public class PicocliTest implements Callable<Integer> {
@CommandLine.ArgGroup(heading = "Group heading%n")
GroupArguments args;
static class GroupArguments {
@CommandLine.ArgGroup(exclusive = false, multiplicity = "1")
AorB aorb;
static class AorB {
@CommandLine.Option(names = {"--a"})
protected String a;
@CommandLine.Option(names = {"--b"})
protected String b;
}
@CommandLine.Option(required = true, names = {"--important"})
protected boolean important;
@CommandLine.Option(names = {"--notImportant"})
protected boolean notImportant;
}
@CommandLine.Option(names = {"--alsoNotImportant"})
protected boolean alsoNotImportant;
public static void main(String[] args) {
new CommandLine(new PicocliTest()).execute(args);
}
@Override
public Integer call() throws Exception {
System.out.println(args.aorb.a);
return 0;
}
}
picocli happily enters the program without any arguments. Setting multiplicity="1"
for the args-group does not solve the problem because specifying --notImportant
will again run the program just fine.