question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unmatched argument

See original GitHub issue

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 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
remkopcommented, Jan 19, 2021

No worries. It’s proof you are human. 🚫 👽 😄

Enjoy picocli! (And please give picocli a ⭐ star on GitHub if you like the project. 😉 )

0reactions
mininotallarinescommented, Jan 19, 2021

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 😕

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found