Skip to content

Commit b0d7084

Browse files
committed
[#226] Bugfix: EmptyStackException when command line ends in a cluster of boolean options
Closes #226
1 parent 846ace0 commit b0d7084

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

RELEASE-NOTES.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
## <a name="2.1.0-fixes"></a> Fixed issues
66

7-
- [#220] Improve tracing for positional parameters (provide detail on current position).
8-
- [#221] Document workaround for Grapes bug on Groovy versions before 2.4.7.
9-
- [#222] Register default converter for Object fields for better scripting support.
10-
- [#219] Command line system property -Dpicocli.trace (without value) throws exception when used with Groovy.
7+
- [#226] Bugfix: EmptyStackException when command line ends in a cluster of boolean options
8+
- [#222] Bugfix: Register default converter for Object fields for better scripting support.
9+
- [#219] Bugfix: Command line system property -Dpicocli.trace (without value) throws exception when used with Groovy.
10+
- [#220] Enhancement: Improve tracing for positional parameters (provide detail on current position).
11+
- [#221] Enhancement: Document workaround for Grapes bug on Groovy versions before 2.4.7.
1112

1213
# <a name="2.0.1"></a> Picocli 2.0.1
1314

src/main/java/picocli/CommandLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ private void processClusteredShortOptions(Collection<Field> required,
21662166
}
21672167
int consumed = applyOption(field, Option.class, arity, paramAttachedToOption, args, initialized, argDescription);
21682168
// only return if cluster (and maybe more) was consumed, otherwise continue do-while loop
2169-
if (consumed > 0) {
2169+
if (consumed > 0 || args.isEmpty()) {
21702170
return;
21712171
}
21722172
cluster = args.pop();

src/test/java/picocli/CommandLineTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,4 +3122,21 @@ class Top {
31223122
assertEquals("OPT", ((Top) parsed.get(0).getCommand()).option);
31233123
assertEquals("ABC", ((Sub207A) parsed.get(1).getCommand()).x);
31243124
}
3125+
@Test
3126+
public void testIssue226EmptyStackWithClusteredOptions() {
3127+
class Options {
3128+
@Option(names = "-b")
3129+
private boolean buffered = false;
3130+
3131+
@Option(names = "-o")
3132+
private boolean overwriteOutput = true;
3133+
3134+
@Option(names = "-v")
3135+
private boolean verbose = false;
3136+
}
3137+
Options options = CommandLine.populateCommand(new Options(), "-bov");
3138+
assertTrue(options.buffered);
3139+
assertFalse(options.overwriteOutput);
3140+
assertTrue(options.verbose);
3141+
}
31253142
}

0 commit comments

Comments
 (0)