Skip to content

Commit 319c641

Browse files
committed
[#1183] Bugfix: Prevent MissingParameterException thrown when subcommand has required options and help option is specified on parent command
Closes #1183
1 parent f66251d commit 319c641

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ only single-value types, and the values in a `Map` (but not the keys!) can be wr
118118
* [#1229] Bugfix: Fix compilation error introduced with fc5ef6de6 (#1184). Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
119119
* [#1225] Bugfix: Error message for unmatched positional argument reports incorrect index when value equals a previously matched argument. Thanks to [Vitaly Shukela](https://github.com/vi) for raising this.
120120
* [#1250] Bugfix: Inherited positional parameter should not be overridden by default value if placed after subcommand. Thanks to [Daniel Gray](https://github.com/danielthegray) for the pull request.
121+
* [#1183] Bugfix: Prevent `MissingParameterException` thrown when subcommand has required options and help option is specified on parent command. Thanks to [drkilikil](https://github.com/drkilikil) for raising this.
121122
* [#1215] DOC: User manual improvements, including more tabs with Kotlin source code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
122123
* [#1219] DOC: User manual improvements: added more tabs with Kotlin code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
123124
* [#1220] DOC: User manual improvements: corrections, more Kotlin tabs. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.

src/main/java/picocli/CommandLine.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12619,7 +12619,13 @@ private void parse(List<CommandLine> parsedCommands, Stack<String> argumentStack
1261912619
}
1262012620
} while (!argumentStack.isEmpty() && continueOnError);
1262112621

12622-
if (!isAnyHelpRequested()) {
12622+
boolean anyHelpRequested = isAnyHelpRequested();
12623+
CommandLine parsed = CommandLine.this;
12624+
while (parsed.getParent() != null) {
12625+
parsed = parsed.getParent();
12626+
anyHelpRequested |= parsed.interpreter.isAnyHelpRequested();
12627+
}
12628+
if (!anyHelpRequested) {
1262312629
validateConstraints(argumentStack, required, initialized);
1262412630
}
1262512631
}

src/test/java/picocli/SubcommandTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,6 @@ class InhSub {
27362736
assertEquals("An inheritable parameter rooted in a subcommand's root was not itself!", subParamRooted, subsubParamFromSub.root());
27372737
}
27382738

2739-
@Ignore("requires #1183")
27402739
@Test
27412740
public void testIssue1183_HelpWithSubcommandWithRequiredOptions() {
27422741
@Command(name = "app", mixinStandardHelpOptions = true)

0 commit comments

Comments
 (0)