[
https://issues.apache.org/jira/browse/CLI-354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081385#comment-18081385
]
Gary D. Gregory commented on CLI-354:
-------------------------------------
CC [~claude]
This think this might be worse... if I set the max width to 6, the description
is not wrapper properly with a narrow width. For example:
{code:java}
// THIS WILL FAIL, WHAT SHOULD REALLY HAPPEN WITH serializer.setMaxWidth(6)?
@Test
void testDescriptionWrapping() throws IOException {
final StringBuilder sb = new StringBuilder();
final TextHelpAppendable serializer = new TextHelpAppendable(sb);
serializer.setMaxWidth(6);
final Options options = new
Options().addOption(Option.builder("a").hasArg().desc("aaaa aaaa aaaa aaaa aaaa
aaaa aaaa aaaa aaaa aaaa").get());
List<String> expected = new ArrayList<>();
HelpFormatter formatter =
HelpFormatter.builder().setShowSince(false).setHelpAppendable(serializer).get();
expected = new ArrayList<>();
expected.add(" usage: cs [-a <arg>]");
expected.add("");
expected.add(" header");
expected.add("");
expected.add(" Options Description");
expected.add(" -a <arg> aaaa aaaa ");
expected.add(" aaaa aaaa ");
expected.add(" aaaa aaaa ");
expected.add(" aaaa aaaa ");
expected.add(" aaaa aaaa ");
expected.add("");
expected.add(" footer");
expected.add("");
formatter.printHelp("cs", "header", options, "footer", true);
List<String> actual = IOUtils.readLines(new
StringReader(sb.toString()));
assertEquals(expected, actual);
}
{code}
> HelpFormatter: Description indentation is incorrect
> ---------------------------------------------------
>
> Key: CLI-354
> URL: https://issues.apache.org/jira/browse/CLI-354
> Project: Commons CLI
> Issue Type: Bug
> Components: Help formatter
> Affects Versions: 1.11.0
> Reporter: Roman Huber
> Priority: Minor
>
> When using {{{}HelpFormatter{}}}, the description lines are not indented
> consistently.
> As an example, I get this output:
> {noformat}
> -V, --argument-value <value> an argument passed to the remote
> command. The value will be wrapped
> in double quotes and appended to the
> command-line. This option can be
> added multiple times.
> {noformat}
> As shown above, the wrapped description lines are not aligned correctly. Some
> lines are indented one space less than others.
> h4. Expected behavior
> All wrapped description lines should be indented equally, with the exception
> of the first line.
> h4. Suspected cause
> The issue appears to be caused by an incorrect comparison in the indentation
> logic. The
> [condition|https://github.com/apache/commons-cli/blob/7be3807fa6fd4ad29241074f6ddeb23cfc677775/src/main/java/org/apache/commons/cli/help/TextStyle.java#L372]
> currently checks:
> {code:java}
> restLen > indent
> {code}
> It should instead be:
> {code:java}
> restLen >= indent
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)