-
Notifications
You must be signed in to change notification settings - Fork 440
Closed
Labels
Milestone
Description
If a command is defined with only named parameters and no positional parameters, and this command is invoked with an empty string as a parameter, the error message is unclear:
#invoke
<cmd> ""
Actual result:
Unmatched argument:
Usage: <main class> [--option]
...
Expected result:
Unmatched argument '' at index 0
Usage: <main class> [--option]
...
Breaking Test:
@Test
public void testUnmatchedWithEmptyPositional() {
@Command class App {
@Option(names = "-x") List<Object> unmatched;
}
CommandLine cmd = new CommandLine(new App());
try {
cmd.parse("");
fail("Expected exception");
} catch (UnmatchedArgumentException ex) {
assertEquals("Unmatched argument at index 0: ''", ex.getMessage());
}
}