You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With version 4.0.2-SNAPSHOT I am facing a DuplicateOptionAnnotationsException in a particular use case. The mixin is using a nested group inside of a group. I managed to generate a simple test case that reproduce the issue:
Test code:
@picocli.CommandLine.Command(name = "test-with-mixin-and-nested-group",
description = "Picocli section test with mixin and nested group.",
abbreviateSynopsis = true,
sortOptions = false)
public class Test {
@Mixin
TestConfig testConfig = new TestConfig();
private static class TestConfig {
@ArgGroup(validate = false, heading = "A1%n")
private final A1 a1 = new A1();
private static class A1 {
@ArgGroup(exclusive = true)
private final NestedA1 nestedA1 = new NestedA1();
private static class NestedA1 {
@Option(names = {"-ta1", "--test-a1"})
private String testA1;
@Option(names = {"-ta2", "--test-a2"})
private String testA2;
}
}
@ArgGroup(validate = false, heading = "A2%n")
private final A2 a2 = new A2();
private static class A2 {
@Option(names = {"-tb1", "--test-b1"})
private String testB1;
@Option(names = {"-tb2", "--test-b2"})
private String testB2;
}
}
/**
* Picocli test.
*/
public static void main(String[] args) {
new CommandLine(new Test()).usage(System.out);
}
}
Output:
picocli.CommandLine$DuplicateOptionAnnotationsException: Option name '-ta2' is used by both field String com.ongres.egres.TestPicocliHeadingSection$TestWithNestedMixin$TestConfig$A1$NestedA1.testA2 and field String com.ongres.egres.TestPicocliHeadingSection$TestWithNestedMixin$TestConfig$A1$NestedA1.testA2
at picocli.CommandLine$DuplicateOptionAnnotationsException.create(CommandLine.java:15027)
at picocli.CommandLine$DuplicateOptionAnnotationsException.access$1700(CommandLine.java:15021)
at picocli.CommandLine$Model$CommandSpec.addOption(CommandLine.java:5381)
at picocli.CommandLine$Model$CommandSpec.addMixin(CommandLine.java:5567)
at picocli.CommandLine$Model$CommandReflection.initFromAnnotatedTypedMembers(CommandLine.java:9641)
at picocli.CommandLine$Model$CommandReflection.initFromAnnotatedFields(CommandLine.java:9621)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:9532)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:5116)
at picocli.CommandLine.<init>(CommandLine.java:223)
at picocli.CommandLine.<init>(CommandLine.java:196)
at Test.main(Test.java:45)
With version 4.0.2-SNAPSHOT I am facing a
DuplicateOptionAnnotationsException
in a particular use case. The mixin is using a nested group inside of a group. I managed to generate a simple test case that reproduce the issue:Originally posted by @teoincontatto in #776 (comment)
The text was updated successfully, but these errors were encountered: