picocli
picocli copied to clipboard
"Parsed command (...) is not a Method, Runnable or Callable" not recognized by annotation processor
The "Parsed command (...) is not a Method, Runnable or Callable" error is not reported by the annotation processor, but only complained about at runtime in 4.6.3.
@Vampire Can you show how to reproduce this?
Just annotate a class that is not Runnable
or Callable
with @Command
and build with annotation processor configured.
The annotation processor will not complain but at runtime it fails.
I see. thank you for the clarification. Are you interested in providing a pull request for this?
Currently not, sorry. I'm too busy with other stuff and it does not bite me enough. :-)
Understood. Thanks for letting me know!
Also while reading the "Required Subcommands" section, I'd say that the error message is missing "and does not have subcommands" in which case it would have been valid.
Sorry, I don't follow... Are you saying that the example in the Required Subcommands section, that currently looks like this:
@Command(name = "git", synopsisSubcommandLabel = "COMMAND", subcommands = { ... })
class Git implements Runnable {
@Spec CommandSpec spec;
public void run() {
throw new ParameterException(spec.commandLine(), "Missing required subcommand");
}
public static void main(String... args) {
System.exit(new CommandLine(new Git()).execute(args));
}
}
Should look like this instead?
@Command(name = "git", synopsisSubcommandLabel = "COMMAND", subcommands = { ... })
class Git implements Runnable {
@Spec CommandSpec spec;
public void run() {
throw new ParameterException(spec.commandLine(), "Missing required subcommand and does not have subcommands");
}
public static void main(String... args) {
System.exit(new CommandLine(new Git()).execute(args));
}
}
No, that wouldn't make sense.
I reported in this issue, that if you annotate a class that is not Runnable
or Callable
with @Command
and build with annotation processor configured.
The annotation processor will not complain but at runtime it fails with message "Parsed command (...) is not a Method, Runnable or Callable".
Additionally in this message "and does not have subcommands" is missing, as annotating a class that is not Runnable
or Callable
is fine if you have subcommands and just makes the subcommands mandatory.