This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-cli.git
commit f755c610191d4d974922bd1fdd523c3b493f928a Author: Gary Gregory <[email protected]> AuthorDate: Sat Aug 29 07:55:39 2026 -0400 Sort members. --- .../apache/commons/cli/help/HelpFormatterTest.java | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java b/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java index e7b995bc..03959de3 100644 --- a/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java +++ b/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java @@ -259,6 +259,39 @@ class HelpFormatterTest { assertEquals(0, sb.length(), "Should not write to output"); } + /** + * Continuation description lines must share the same indent. + * + * @see <a href="https://issues.apache.org/jira/browse/CLI-354">[CLI-354] HelpFormatter: Description indentation is incorrect</a> + */ + @Test + void testPrintHelpWrappedDescriptionIndent() throws IOException { + final StringBuilder sb = new StringBuilder(); + final TextHelpAppendable serializer = new TextHelpAppendable(sb); + final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).setShowSince(false).get(); + final String description = "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."; + final Options options = new Options().addOption(Option.builder("V").longOpt("argument-value").hasArg().desc(description).get()); + + final List<String> expected = new ArrayList<>(); + expected.add(" usage: cs [-V <arg>]"); + expected.add(""); + expected.add(" header"); + expected.add(""); + expected.add(" Options Description "); + expected.add(" -V, --argument-value <arg> an argument passed to the remote command. "); + expected.add(" The value will be wrapped in double quotes"); + expected.add(" and appended to the command-line. This "); + expected.add(" option can be added multiple times. "); + expected.add(""); + expected.add(" footer"); + expected.add(""); + + formatter.printHelp("cs", "header", options, "footer", true); + final List<String> actual = IOUtils.readLines(new StringReader(sb.toString())); + assertEquals(expected, actual); + } + @Test void testPrintHelpXML() throws IOException { final StringBuilder sb = new StringBuilder(); @@ -340,39 +373,6 @@ class HelpFormatterTest { assertEquals(expected, actual); } - /** - * Continuation description lines must share the same indent. - * - * @see <a href="https://issues.apache.org/jira/browse/CLI-354">[CLI-354] HelpFormatter: Description indentation is incorrect</a> - */ - @Test - void testPrintHelpWrappedDescriptionIndent() throws IOException { - final StringBuilder sb = new StringBuilder(); - final TextHelpAppendable serializer = new TextHelpAppendable(sb); - final HelpFormatter formatter = HelpFormatter.builder().setHelpAppendable(serializer).setShowSince(false).get(); - final String description = "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."; - final Options options = new Options().addOption(Option.builder("V").longOpt("argument-value").hasArg().desc(description).get()); - - final List<String> expected = new ArrayList<>(); - expected.add(" usage: cs [-V <arg>]"); - expected.add(""); - expected.add(" header"); - expected.add(""); - expected.add(" Options Description "); - expected.add(" -V, --argument-value <arg> an argument passed to the remote command. "); - expected.add(" The value will be wrapped in double quotes"); - expected.add(" and appended to the command-line. This "); - expected.add(" option can be added multiple times. "); - expected.add(""); - expected.add(" footer"); - expected.add(""); - - formatter.printHelp("cs", "header", options, "footer", true); - final List<String> actual = IOUtils.readLines(new StringReader(sb.toString())); - assertEquals(expected, actual); - } - @Test void testSetOptionFormatBuilderTest() { final HelpFormatter.Builder underTest = HelpFormatter.builder();
