diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 7985f4d22..57bff4913 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -5995,13 +5995,13 @@ private Model() {} * @since 4.0 */ public interface IScope extends IGetter, ISetter {} - - /** This interface provides access to an {@link IScope} instance. + + /** This interface provides access to an {@link IScope} instance. * @since 4.7 */ public interface IScoped { /** Get the {@link IScope} instance. - * + * * @return {@link IScope} instance */ IScope getScope(); } @@ -9176,8 +9176,8 @@ private String defaultValueFromProvider() { * @return whether this argument applies to all descendent subcommands of the command where it is defined * @since 4.3 */ public ScopeType scopeType() { return scopeType; } - - /** Check whether the {@link #getValue()} method is able to get an actual value from the current {@link #getter()}. + + /** Check whether the {@link #getValue()} method is able to get an actual value from the current {@link #getter()}. * @since 4.7 */ public boolean isValueGettable() { if (getter instanceof IScoped) { @@ -15754,14 +15754,17 @@ static Text concatOptionText(String prefix, Text text, Help.ColorScheme colorSch Text name = colorScheme.optionText(nameString); Text param = parameterLabelRenderer.renderParameterLabel(option, colorScheme.ansi(), colorScheme.optionParamStyles); text = text.concat(prefix); + + // related: Interpreter#getActualTypeConverter special logic for interactive char[] options... (also: #648) + boolean treatAsSingleValue = char[].class.equals(option.type()) && option.interactive(); // #1834 if (option.required()) { // e.g., -x=VAL text = text.concat(name).concat(param).concat(""); - if (option.isMultiValue()) { // e.g., -x=VAL [-x=VAL]... + if (option.isMultiValue() && !treatAsSingleValue) { // e.g., -x=VAL [-x=VAL]... text = text.concat(" [").concat(name).concat(param).concat("]..."); } } else { text = text.concat("[").concat(name).concat(param).concat("]"); - if (option.isMultiValue()) { // add ellipsis to show option is repeatable + if (option.isMultiValue() && !treatAsSingleValue) { // add ellipsis to show option is repeatable text = text.concat("..."); } } diff --git a/src/test/java/picocli/HelpTest.java b/src/test/java/picocli/HelpTest.java index 9c7f8c8d7..3baeb2ff3 100644 --- a/src/test/java/picocli/HelpTest.java +++ b/src/test/java/picocli/HelpTest.java @@ -5180,4 +5180,14 @@ public Text[][] render(OptionSpec option, IParamLabelRenderer ignored, ColorSche String actual = cmd.getUsageMessage(); assertEquals(expected, actual); } + + @Test + public void testIssue1834SynopsisForCharArrayOption() { + @Command() class App { + @Option(names = {"--password", "-p"}, interactive = true, echo = false, arity = "0..1", required = true) + private char[] password;; + } + Help help = new Help(new App()); + assertEquals("
-p[=]" + LINESEP, help.synopsis(0)); + } }