You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
This change has been included in the 4.0.0-beta-1b release that just came out.
I added a test but it would be good if you can confirm the problem no longer exists.
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: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.Now, when I call
CommandSpec.forAnnotatedObject(MyCommand.class, factory)
, whereMyCommand
extendsSubcommand
, 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 toSubcommand
inheriting the annotation onAbstractCommand
.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?
The text was updated successfully, but these errors were encountered: