@@ -15346,7 +15346,7 @@ static class AutoHelpMixin {
15346
15346
synopsisHeading = "%nUsage: ", helpCommand = true,
15347
15347
description = {"%nWhen no COMMAND is given, the usage help for the main command is displayed.",
15348
15348
"If a COMMAND is specified, the help for that command is shown.%n"})
15349
- public static final class HelpCommand implements IHelpCommandInitializable, IHelpCommandInitializable2, Runnable {
15349
+ public static final class HelpCommand implements IHelpCommandInitializable, IHelpCommandInitializable2, Callable<Integer> {
15350
15350
15351
15351
@Option(names = {"-h", "--help"}, usageHelp = true, descriptionKey = "helpCommand.help",
15352
15352
description = "Show usage help for the help command and exit.")
@@ -15365,9 +15365,11 @@ public static final class HelpCommand implements IHelpCommandInitializable, IHel
15365
15365
private Help.ColorScheme colorScheme;
15366
15366
15367
15367
/** Invokes {@link #usage(PrintStream, Help.ColorScheme) usage} for the specified command, or for the parent command. */
15368
- public void run() {
15368
+ @Override
15369
+ public Integer call () {
15370
+ // TODO: self can't be null here, why the check?
15369
15371
CommandLine parent = self == null ? null : self.getParent();
15370
- if (parent == null) { return; }
15372
+ if (parent == null) { return self.getCommandSpec ().exitCodeOnUsageHelp () ; }
15371
15373
Help.ColorScheme colors = colorScheme != null ? colorScheme : Help.defaultColorScheme(ansi);
15372
15374
if (commands != null) {
15373
15375
Map<String, CommandLine> parentSubcommands = parent.getCommandSpec().subcommands();
@@ -15382,6 +15384,7 @@ public void run() {
15382
15384
} else {
15383
15385
subcommand.usage(out, colors); // for compatibility with pre-4.0 clients
15384
15386
}
15387
+ return subcommand.getCommandSpec ().exitCodeOnUsageHelp ();
15385
15388
} else {
15386
15389
throw new ParameterException(parent, "Unknown subcommand '" + commands + "'.", null, commands);
15387
15390
}
@@ -15391,6 +15394,7 @@ public void run() {
15391
15394
} else {
15392
15395
parent.usage(out, colors); // for compatibility with pre-4.0 clients
15393
15396
}
15397
+ return parent.getCommandSpec ().exitCodeOnUsageHelp ();
15394
15398
}
15395
15399
}
15396
15400
/** {@inheritDoc} */
0 commit comments