[#1183] Bugfix: Prevent MissingParameterException thrown when subcommand has required options and help option is specified on parent command

Closes #1183
This commit is contained in:
Remko Popma
2020-11-12 20:08:26 +09:00
parent f66251dc8b
commit 319c6418c8
3 changed files with 8 additions and 2 deletions

View File

@@ -118,6 +118,7 @@ only single-value types, and the values in a `Map` (but not the keys!) can be wr
* [#1229] Bugfix: Fix compilation error introduced with fc5ef6de6 (#1184). Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1229] Bugfix: Fix compilation error introduced with fc5ef6de6 (#1184). Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#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. * [#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.
* [#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. * [#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.
* [#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.
* [#1215] DOC: User manual improvements, including more tabs with Kotlin source code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1215] DOC: User manual improvements, including more tabs with Kotlin source code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1219] DOC: User manual improvements: added more tabs with Kotlin code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1219] DOC: User manual improvements: added more tabs with Kotlin code. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1220] DOC: User manual improvements: corrections, more Kotlin tabs. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request. * [#1220] DOC: User manual improvements: corrections, more Kotlin tabs. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.

View File

@@ -12619,7 +12619,13 @@ public class CommandLine {
} }
} while (!argumentStack.isEmpty() && continueOnError); } while (!argumentStack.isEmpty() && continueOnError);
if (!isAnyHelpRequested()) { boolean anyHelpRequested = isAnyHelpRequested();
CommandLine parsed = CommandLine.this;
while (parsed.getParent() != null) {
parsed = parsed.getParent();
anyHelpRequested |= parsed.interpreter.isAnyHelpRequested();
}
if (!anyHelpRequested) {
validateConstraints(argumentStack, required, initialized); validateConstraints(argumentStack, required, initialized);
} }
} }

View File

@@ -2736,7 +2736,6 @@ public class SubcommandTests {
assertEquals("An inheritable parameter rooted in a subcommand's root was not itself!", subParamRooted, subsubParamFromSub.root()); assertEquals("An inheritable parameter rooted in a subcommand's root was not itself!", subParamRooted, subsubParamFromSub.root());
} }
@Ignore("requires #1183")
@Test @Test
public void testIssue1183_HelpWithSubcommandWithRequiredOptions() { public void testIssue1183_HelpWithSubcommandWithRequiredOptions() {
@Command(name = "app", mixinStandardHelpOptions = true) @Command(name = "app", mixinStandardHelpOptions = true)