-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
Milestone
Description
Example:
SuperClass.java
import picocli.CommandLine.Command;
@Command(name="super")
public class SuperClass implements Runnable {
@Override
public void run() {
// TODO: Implement this method
}
}
SubClass.java
import picocli.CommandLine.Command;
@Command(name="sub")
public class SubClass extends SuperClass {
@Command(name="method")
public void method() {}
}
Main.java
import picocli.CommandLine;
import picocli.CommandLine.Command;
@Command(name="main", subcommands= {SuperClass.class, SubClass.class})
public class Main implements Runnable {
@Override
public void run() {
// TODO: Implement this method
}
public static void main(String[] args) {
CommandLine.run(new Main(), "");
}
}
The error
picocli.CommandLine$InitializationException: Another subcommand named 'method' already exists for command 'sub'
at picocli.CommandLine$Model$CommandSpec.addSubcommand(CommandLine.java:3697)
at picocli.CommandLine$Model$CommandSpec.addMethodSubcommands(CommandLine.java:3740)
at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:5950)
at picocli.CommandLine$Model$CommandReflection.updateCommandAttributes(CommandLine.java:5930)
at picocli.CommandLine$Model$CommandReflection.updateCommandAttributes(CommandLine.java:5914)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:5884)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:3580)
at picocli.CommandLine.<init>(CommandLine.java:185)
at picocli.CommandLine.toCommandLine(CommandLine.java:2254)
at picocli.CommandLine.access$8300(CommandLine.java:142)
at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:5937)
at picocli.CommandLine$Model$CommandReflection.updateCommandAttributes(CommandLine.java:5930)
at picocli.CommandLine$Model$CommandReflection.updateCommandAttributes(CommandLine.java:5914)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:5884)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:3580)
at picocli.CommandLine.<init>(CommandLine.java:185)
at picocli.CommandLine.<init>(CommandLine.java:164)
at picocli.CommandLine.run(CommandLine.java:1863)
at picocli.CommandLine.run(CommandLine.java:1794)
at Main.main(Main.java:13)
at java.lang.reflect.Method.invoke(Native Method)
at com.aide.ui.build.java.RunJavaActivity$1.run(SourceFile:108)
at java.lang.Thread.run(Thread.java:764)
It works if I remove the @Command
annotation from SuperClass
, or it works if I turn method()
into a class and add it to SubClass
's subcommands
, but not with SuperClass
being a @Command
and method()
being a method.