picocli icon indicating copy to clipboard operation
picocli copied to clipboard

Reusing CommandLine object doesn't reset values in argument groups options.

Open valepakh opened this issue 2 years ago • 0 comments

The following test fails:

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

    @Command(name = "command")
    static class Command implements Runnable {
        @Option(names = "--option")
        private String option;
        
        @ArgGroup
        private Group group;

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

        @Override
        public void run() {
        }
    }

valepakh avatar Aug 05 '22 12:08 valepakh