Skip to content

Commit

Permalink
[#1768] add test
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Oct 31, 2022
1 parent cf432ed commit 94bc75d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/test/java/picocli/ArgGroupTest.java
Expand Up @@ -4351,4 +4351,30 @@ public void testIssue1680MultiplicityZeroCausesInfiniteLoop() {
}
}

@Test
public void testReuseBothCommandLineAndUserObjectWithArgGroup() {
MyCommand userObject = new MyCommand();
CommandLine cmdLine = new CommandLine(userObject);
cmdLine.execute("--group", "group", "--option", "option");
cmdLine.execute();
assertNull("Expected option to be reset to null", userObject.option);
assertNull("Expected group option to be reset to null", userObject.group.option);
}

@Command(name = "command")
static class MyCommand implements Runnable {
@Option(names = "--option"/*, defaultValue = Option.NULL_VALUE*/)
private String option;

@ArgGroup
private Group group = new Group();

private static class Group {
@Option(names = "--group", defaultValue = Option.NULL_VALUE)
private String option;
}

public void run() {
}
}
}

0 comments on commit 94bc75d

Please sign in to comment.