-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
status: in-progress 👷♂️theme: arg-groupAn issue or change related to argument groupsAn issue or change related to argument groups
Milestone
Description
Hello,
When using the features ArgsGroup along with defaultValue
and split
, the value reported from the second group is not correct as per the arguments provided.
Sample code with error:
public class TestParser {
public static void main(String[] ignore) {
String[] rawArgs = new String[]{
"--type=ONE", "--actions=CREATE,DELETE",
"--type=TWO", "--actions=CREATE",
"--type=THREE",
"--type=FOUR", "--actions=CREATE,UPDATE"
};
Args args = new Args();
new CommandLine(args).parseArgs(rawArgs);
args.groups.forEach(g -> System.out.printf("%5s = %s\n", g.type, g.actions));
}
public static class Args {
@ArgGroup(exclusive = false, multiplicity = "1..4")
private List<Group> groups;
}
public static class Group {
@Option(names = "--type", required = true)
private String type;
@Option(names = "--actions", defaultValue = "CREATE,UPDATE,DELETE", split = ",")
private Set<String> actions;
}
}
Actual Result:
ONE = [CREATE, DELETE]
TWO = [CREATE, UPDATE, DELETE]
THREE = [CREATE, UPDATE, DELETE]
FOUR = [CREATE, UPDATE, DELETE]
Expected Result:
ONE = [CREATE, DELETE]
TWO = [CREATE]
THREE = [CREATE, UPDATE, DELETE]
FOUR = [CREATE, UPDATE]
Here, we can see that the results are using the default value starting from the second item in the ArgGroup.
Details:
JDK: temurin-21.jdk
Picocli version: 4.7.6
Metadata
Metadata
Assignees
Labels
status: in-progress 👷♂️theme: arg-groupAn issue or change related to argument groupsAn issue or change related to argument groups