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
With the latest HEAD (846ace0 as of writing this) processing clustered short options seems to be broken. Assume that I have a Command class with three flags, like this:
With the input of -bov the following exception is thrown:
Exception in thread "main" picocli.CommandLine$ParameterException: EmptyStackException: null while processing argument at or before arg[0] '-bov' in [-bov]: java.util.EmptyStackException
at picocli.CommandLine$ParameterException.create(CommandLine.java:4613)
at picocli.CommandLine$ParameterException.access$0(CommandLine.java:4610)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:1978)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:1955)
at picocli.CommandLine.parse(CommandLine.java:346)
at picocli.CommandLine.populateCommand(CommandLine.java:327)
at picocli.FlagsMain.main(FlagsMain.java:72)
Caused by: java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at java.util.Stack.pop(Stack.java:84)
at picocli.CommandLine$Interpreter.processClusteredShortOptions(CommandLine.java:2172)
at picocli.CommandLine$Interpreter.processArguments(CommandLine.java:2059)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:1972)
... 4 more
Form what I can gather, that seems to be because the processing of clustered options is not exiting when there are no more clustered options. I fixed it locally by using the following patch:
diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java
index 72c6ad9..782e9bd 100644
--- a/src/main/java/picocli/CommandLine.java+++ b/src/main/java/picocli/CommandLine.java@@ -2166,7 +2166,7 @@ public class CommandLine {
}
int consumed = applyOption(field, Option.class, arity, paramAttachedToOption, args, initialized, argDescription);
// only return if cluster (and maybe more) was consumed, otherwise continue do-while loop
- if (consumed > 0) {+ if (consumed > 0 || args.isEmpty()) {
return;
}
cluster = args.pop();
But I'm unsure if that is the best option.
The text was updated successfully, but these errors were encountered:
With the latest HEAD (846ace0 as of writing this) processing clustered short options seems to be broken. Assume that I have a Command class with three flags, like this:
With the input of
-bov
the following exception is thrown:Form what I can gather, that seems to be because the processing of clustered options is not exiting when there are no more clustered options. I fixed it locally by using the following patch:
But I'm unsure if that is the best option.
The text was updated successfully, but these errors were encountered: