-
Notifications
You must be signed in to change notification settings - Fork 440
Description
Hi there,
I keep running into the following exception
picocli.CommandLine$InitializationException: Another subcommand named 'help' already exists for command '<main class>'
I know what the cause of this is but I don't know how to fix it.
I have an abstract class AbstractCommand
which is annotated so that every class extending it automatically has a specified (custom) help command:
@CommandLine.Command(subcommands = HelpCommand.class)
public abstract class AbstractCommand {
...
}
All my commands are extending this abstract class and this hasn't caused any issues thus far.
The problem arises when I make another abstract class extending AbstractCommand
e.g.
public abstract class Subcommand extends AbstractCommand {
...
}
Now, when I call CommandSpec.forAnnotatedObject(MyCommand.class, factory)
, where MyCommand
extends Subcommand
, it will throw an exception telling me that it already has a help command. I couldn't find the exact cause for the issue in the picocli source code but I can only assume that it is trying to add the help command twice due to Subcommand
inheriting the annotation on AbstractCommand
.
I would like to add that this only occurs on version 4.0.0-alpha-2 and up, worked just fine before that.
Perhaps it is related to this?