diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 9d001f5c4..b8dbd7ddf 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -14751,9 +14751,9 @@ public static final class HelpCommand implements IHelpCommandInitializable, IHel description = "Show usage help for the help command and exit.") private boolean helpRequested; - @Parameters(paramLabel = "COMMAND", descriptionKey = "helpCommand.command", + @Parameters(paramLabel = "COMMAND", arity="0..1", descriptionKey = "helpCommand.command", description = "The COMMAND to display the usage help message for.") - private String[] commands = new String[0]; + private String commands; private CommandLine self; private PrintStream out; @@ -14768,9 +14768,9 @@ public void run() { CommandLine parent = self == null ? null : self.getParent(); if (parent == null) { return; } Help.ColorScheme colors = colorScheme != null ? colorScheme : Help.defaultColorScheme(ansi); - if (commands.length > 0) { + if (commands != null) { Map parentSubcommands = parent.getCommandSpec().subcommands(); - String fullName = commands[0]; + String fullName = commands; if (parent.isAbbreviatedSubcommandsAllowed()) { fullName = AbbreviationMatcher.match(parentSubcommands.keySet(), fullName, parent.isSubcommandsCaseInsensitive(), self); @@ -14783,7 +14783,7 @@ public void run() { subcommand.usage(out, colors); // for compatibility with pre-4.0 clients } } else { - throw new ParameterException(parent, "Unknown subcommand '" + commands[0] + "'.", null, commands[0]); + throw new ParameterException(parent, "Unknown subcommand '" + commands + "'.", null, commands); } } else { if (outWriter != null) { diff --git a/src/test/java/picocli/HelpSubCommandTest.java b/src/test/java/picocli/HelpSubCommandTest.java index 2468cee53..45e70fa45 100644 --- a/src/test/java/picocli/HelpSubCommandTest.java +++ b/src/test/java/picocli/HelpSubCommandTest.java @@ -346,13 +346,13 @@ class App implements Runnable{ public void run(){}} String expected = String.format("" + "Displays help information about the specified command%n" + "%n" + - "Usage:
help [-h] [COMMAND...]%n" + + "Usage:
help [-h] [COMMAND]%n" + "%n" + "When no COMMAND is given, the usage help for the main command is displayed.%n" + "If a COMMAND is specified, the help for that command is shown.%n" + "%n" + - " [COMMAND...] The COMMAND to display the usage help message for.%n" + - " -h, --help Show usage help for the help command and exit.%n"); + " [COMMAND] The COMMAND to display the usage help message for.%n" + + " -h, --help Show usage help for the help command and exit.%n"); assertEquals(expected, sw.toString()); sw = new StringWriter(); diff --git a/src/test/java/picocli/I18nTest.java b/src/test/java/picocli/I18nTest.java index bb9d8e27c..2b8cf5a81 100644 --- a/src/test/java/picocli/I18nTest.java +++ b/src/test/java/picocli/I18nTest.java @@ -590,14 +590,14 @@ public void testLocalizeBuiltInHelp_Shared() { "Shared header heading%n" + "i18n-sub HELP command header%n" + "%n" + - "Usage: i18n-top i18n-sub help [-h] [COMMAND...]%n" + + "Usage: i18n-top i18n-sub help [-h] [COMMAND]%n" + "Shared description 0%n" + "Shared description 1%n" + "Shared description 2%n" + - " [COMMAND...] Shared description of COMMAND parameter of built-in help%n" + - " subcommand%n" + - " -h, --help Shared description of --help option of built-in help%n" + - " subcommand%n" + + " [COMMAND] Shared description of COMMAND parameter of built-in help%n" + + " subcommand%n" + + " -h, --help Shared description of --help option of built-in help%n" + + " subcommand%n" + "Shared Exit Codes Heading%n" + "These exit codes are blah blah etc.%n" + " 00 (From shared bundle) Normal termination%n" + @@ -625,14 +625,14 @@ public void testLocalizeBuiltInHelp_Specialized() { "Shared header heading%n" + "i18n-top HELP command header%n" + "%n" + - "Usage: i18n-top help [-h] [COMMAND...]%n" + + "Usage: i18n-top help [-h] [COMMAND]%n" + "Shared description 0%n" + "Shared description 1%n" + "Shared description 2%n" + - " [COMMAND...] Specialized description of COMMAND parameter of i18-top%n" + - " help subcommand%n" + - " -h, --help Specialized description of --help option of i18-top help%n" + - " subcommand%n" + + " [COMMAND] Specialized description of COMMAND parameter of i18-top help%n" + + " subcommand%n" + + " -h, --help Specialized description of --help option of i18-top help%n" + + " subcommand%n" + "Shared Exit Codes Heading%n" + "These exit codes are blah blah etc.%n" + " 00 (From shared bundle) Normal termination%n" +