Skip to content

Commit 2987a24

Browse files
HelpCommand, trying to fix remkop#2355 [ci skip]
1 parent 9e5e58e commit 2987a24

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ picocli.iml
1717
/src/test/dejagnu.tests/tmp/
1818
/picocli-tests-java567/gradle/wrapper/dists/**/*.lck
1919
/picocli-tests-java567/gradle/wrapper/dists/**/*.ok
20+
# Eclipse files
21+
.classpath
22+
.project
23+
.settings/

src/main/java/picocli/CommandLine.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -15346,7 +15346,7 @@ static class AutoHelpMixin {
1534615346
synopsisHeading = "%nUsage: ", helpCommand = true,
1534715347
description = {"%nWhen no COMMAND is given, the usage help for the main command is displayed.",
1534815348
"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> {
1535015350

1535115351
@Option(names = {"-h", "--help"}, usageHelp = true, descriptionKey = "helpCommand.help",
1535215352
description = "Show usage help for the help command and exit.")
@@ -15365,9 +15365,11 @@ public static final class HelpCommand implements IHelpCommandInitializable, IHel
1536515365
private Help.ColorScheme colorScheme;
1536615366

1536715367
/** 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?
1536915371
CommandLine parent = self == null ? null : self.getParent();
15370-
if (parent == null) { return; }
15372+
if (parent == null) { return self.getCommandSpec ().exitCodeOnUsageHelp (); }
1537115373
Help.ColorScheme colors = colorScheme != null ? colorScheme : Help.defaultColorScheme(ansi);
1537215374
if (commands != null) {
1537315375
Map<String, CommandLine> parentSubcommands = parent.getCommandSpec().subcommands();
@@ -15382,6 +15384,7 @@ public void run() {
1538215384
} else {
1538315385
subcommand.usage(out, colors); // for compatibility with pre-4.0 clients
1538415386
}
15387+
return subcommand.getCommandSpec ().exitCodeOnUsageHelp ();
1538515388
} else {
1538615389
throw new ParameterException(parent, "Unknown subcommand '" + commands + "'.", null, commands);
1538715390
}
@@ -15391,6 +15394,7 @@ public void run() {
1539115394
} else {
1539215395
parent.usage(out, colors); // for compatibility with pre-4.0 clients
1539315396
}
15397+
return parent.getCommandSpec ().exitCodeOnUsageHelp ();
1539415398
}
1539515399
}
1539615400
/** {@inheritDoc} */

0 commit comments

Comments
 (0)