-
Notifications
You must be signed in to change notification settings - Fork 418
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
Unmatched argument #1309
Comments
Hi @mininotallarines, thank you for raising this! I initially thought this might be related to #1125, Instead of specifying new CommandLine(new TestCommand(), "restart", "rest"); // ensure "restart" and "rest" are separate args
new CommandLine(new TestCommand(), "start", "sta") // ensure "start" and "sta" are separate args |
I'm sorry, I'll change the post, that is a mistake on my part.. I am actually passing in an array so that would translate to separate arguments.. |
I cannot reproduce the issue. @Command(name = "test", mixinStandardHelpOptions = true)
class TestCommand implements Callable<Integer> {
@Spec
CommandSpec spec;
public Integer call() throws Exception {
throw new ParameterException(spec.commandLine(), "Missing required subcommand");
}
@Command(name = "start", description = "start", mixinStandardHelpOptions = true)
public int start(
@Parameters(index = "0", paramLabel = "id") String id) {
System.out.printf("start was called with %s%n", id);
return 111;
}
@Command(name = "restart", description = "restart", mixinStandardHelpOptions = true)
public int restart(
@Parameters(index = "0", paramLabel = "id") String id) {
System.out.printf("restart was called with %s%n", id);
return 222;
}
}
@Test
public void testIssue1309() {
assertEquals(222, new CommandLine(new TestCommand()).execute("restart", "rest"));
assertEquals(111, new CommandLine(new TestCommand()).execute("start", "sta"));
} This test passes and prints the following output:
All seems to be working as expected... Can you try running this test? |
I'm sorry, after 2 days I managed to find the issue in the command parser. So the command ran with what was apparently 1 argument 'rest' or 'sta'.. this is awkward :/ |
No worries. Enjoy picocli! |
This reverts commit 9d91fbd.
This reverts commit 9d91fbd.
Issue
I was playing around with the subcommands and suddenly I got an unmatched argument exception but I think this might bug.
Running the following command
test start sta
ortest restart rest
tries to autocorrect thesta
and/orrest
to their subcommand.The command never runs and it just says
Did you mean: restart or start?
I'm running the command using the
CommandLine
object as follows:Environment
Operating System Windows 10
IDE Eclipse 2020-12 (4.18.0)
Picoclli Picocli version 4.6.1
The text was updated successfully, but these errors were encountered: