Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgGroup validation silently accepts missing subgroup with multiplicity=1 #655

Closed
remkop opened this issue Apr 2, 2019 · 0 comments
Closed
Labels
theme: parser An issue or change related to the parser type: bug 🐛
Milestone

Comments

@remkop
Copy link
Owner

remkop commented Apr 2, 2019

Test to reproduce the issue:

@Command(name = "test-composite")
static class TestComposite {

    @ArgGroup(exclusive = false, multiplicity = "0..*")
    List<OuterGroup> outerList;

    static class OuterGroup {
        @Option(names = "--add-group", required = true) boolean addGroup;

        @ArgGroup(exclusive = false, multiplicity = "1")
        Inner inner;

        static class Inner {
            @Option(names = "--option1", required = true) String option1;
            @Option(names = "--option2", required = true) String option2;
        }
    }
}

@Test
public void testCompositeValidation() {
    TestComposite app = new TestComposite();
    CommandLine cmd = new CommandLine(app);
    try {
        ParseResult parseResult = cmd.parseArgs("--add-group", "--option2=1", "--option1=1", "--add-group");
        fail("Expect exception");
    } catch (MissingParameterException ex) {
        assertEquals("Error: Missing required argument(s): [--add-group (--option1=<option1> --option2=<option2>)]...", ex.getMessage());
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: parser An issue or change related to the parser type: bug 🐛
Projects
None yet
Development

No branches or pull requests

1 participant