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
import picocli.CommandLine;
import picocli.CommandLine.ScopeType;
import picocli.CommandLine.*;
@Command(scope = ScopeType.INHERIT, mixinStandardHelpOptions = true)
public class InheritApp {
@Command()
void sub(@Option(names = "-foo") int foo) {
System.out.printf("Foo: %d", foo);
}
public static void main (String... args) {
new CommandLine(new InheritApp()).execute("sub", "-foo", "42" );
}
}
When running this code, I'm getting
java.lang.IllegalArgumentException: argument type mismatch
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at picocli.CommandLine.executeUserObject(CommandLine.java:1972)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine.execute(CommandLine.java:2078)
at InheritApp.main(InheritApp.java:14)
It's the combination of inherited scope + mixinStandardHelpOptions that's causing trouble here. If I set scope to ScopeType.LOCAL, the sample runs fine.
The text was updated successfully, but these errors were encountered:
In a nutshell: the cause had to do with calculating argument indexes for subcommand methods; the mixinStandardHelpOptions = true does not add method parameters, so is given special treatment. However, when scope = ScopeType.INHERIT, this special treatment should not be applied.
Minimum working example:
When running this code, I'm getting
It's the combination of inherited
scope
+mixinStandardHelpOptions
that's causing trouble here. If I setscope
toScopeType.LOCAL
, the sample runs fine.The text was updated successfully, but these errors were encountered: