Unmatched argument
See original GitHub issueIssue
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
or test restart rest
tries to autocorrect the sta
and/or rest
to their subcommand.
The command never runs and it just says Did you mean: restart or start?
@Command(name = "test", mixinStandardHelpOptions = true)
public class TestCommand implements Callable<Integer> {
@Override
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) { return 0; }
@Command(name = "restart", description = "restart", mixinStandardHelpOptions = true)
public int restart(
@Parameters(index = "0", paramLabel = "id") String id) { return 0; }
}
I’m running the command using the CommandLine
object as follows:
new CommandLine(new TestCommand()).execute("restart", "rest")
new CommandLine(new TestCommand()).execute("start", "sta")
Environment
Operating System Windows 10 IDE Eclipse 2020-12 (4.18.0) Picoclli Picocli version 4.6.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unmatched argument returned when no equal sign used with ...
Issue noticed in app using PicoCLI Java 3.9.2 but also experienced with latest info.picocli:picocli:3.9.5. Command line option code looks ...
Read more >Class CommandLine.UnmatchedArgumentException - Picocli
Class CommandLine.UnmatchedArgumentException ... Exception indicating that a command line argument could not be mapped to any of the fields annotated with ...
Read more >Why doesn't picocli recognize my option from the command ...
Unmatched argument at index 0: 'Greet' Hello world demo Usage: Greet -u=<userName> -u, --user=<userName> The user name.
Read more >picocli.CommandLine.setUnmatchedArgumentsAllowed java ...
Sets whether the end user may specify unmatched arguments on the command line without a {@link UnmatchedArgumentException} being thrown.
Read more >Unmatched arguments from index 2 while trying to generate ...
Unmatched arguments from index 2 while trying to generate java wrapper class web3j ... Unmatched arguments from index 2: 'build\contracts\PKCoin.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No worries. It’s proof you are human. 🚫 👽 😄
Enjoy picocli! (And please give picocli a ⭐ star on GitHub if you like the project. 😉 )
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 😕