This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git
The following commit(s) were added to refs/heads/master by this push:
new 8677d16 Rename to HelpAppendable since it extends Appendable
8677d16 is described below
commit 8677d165903d9ad462afae7b64cd616daf1f6ccd
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Oct 14 15:15:31 2024 -0400
Rename to HelpAppendable since it extends Appendable
- FilterHelpAppendable implements HelpAppendable: Same naming as
FilterOutputStream extends OutputStream which delegates to an
OutputStream
- Was HelpWriter extends Appendable
- Was AbstractHelpWriter implements HelpAppendable
- These are are not kinds of java.io.Writer
---
.../commons/cli/help/AbstractHelpFormatter.java | 50 +++++++++++-----------
...ctHelpWriter.java => FilterHelpAppendable.java} | 6 +--
.../help/{HelpWriter.java => HelpAppendable.java} | 2 +-
.../org/apache/commons/cli/help/HelpFormatter.java | 28 ++++++------
...TextHelpWriter.java => TextHelpAppendable.java} | 6 +--
.../org/apache/commons/cli/help/TextStyle.java | 11 ++---
.../apache/commons/cli/help/HelpFormatterTest.java | 20 ++++-----
.../commons/cli/help/TextHelpWriterTest.java | 34 +++++++--------
.../{AptHelpWriter.java => AptHelpAppendable.java} | 6 +--
.../commons/example/cli/AptHelpWriterTest.java | 2 +-
...tmlHelpWriter.java => XhtmlHelpAppendable.java} | 8 ++--
.../commons/example/cli/XhtmlHelpWriterTest.java | 2 +-
12 files changed, 88 insertions(+), 87 deletions(-)
diff --git
a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
index 2a5e77f..6312fa8 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
@@ -32,8 +32,8 @@ import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
/**
- * The class for help formatters provides the framework to link the {@link
HelpWriter} with the {@link OptionFormatter} and a default {@link
TableDefinition} so
- * to produce a standard format help page.
+ * The class for help formatters provides the framework to link the {@link
HelpAppendable} with the {@link OptionFormatter} and a default
+ * {@link TableDefinition} so to produce a standard format help page.
*
* @since 1.10.0
*/
@@ -53,9 +53,9 @@ public abstract class AbstractHelpFormatter {
public static final Comparator<Option> DEFAULT_COMPARATOR = (opt1, opt2)
-> opt1.getKey().compareToIgnoreCase(opt2.getKey());
/**
- * The {@link HelpWriter} that produces the final output.
+ * The {@link HelpAppendable} that produces the final output.
*/
- protected final HelpWriter helpWriter;
+ protected final HelpAppendable helpAppendable;
/**
* The OptionFormatter.Builder used to display options within the help page
*/
@@ -74,14 +74,14 @@ public abstract class AbstractHelpFormatter {
/**
* Constructs the base formatter.
*
- * @param helpWriter the helpWriter to output with
+ * @param helpAppendable the helpAppendable to output with
* @param optionFormatBuilder the builder of {@link OptionFormatter} to
format options for display.
* @param comparator The comparator to use for sorting options.
* @param optionGroupSeparator the string to separate option groups.
*/
- protected AbstractHelpFormatter(final HelpWriter helpWriter, final
OptionFormatter.Builder optionFormatBuilder, final Comparator<Option>
comparator,
+ protected AbstractHelpFormatter(final HelpAppendable helpAppendable, final
OptionFormatter.Builder optionFormatBuilder, final Comparator<Option>
comparator,
final String optionGroupSeparator) {
- this.helpWriter = Objects.requireNonNull(helpWriter, "helpWriter");
+ this.helpAppendable = Objects.requireNonNull(helpAppendable,
"helpAppendable");
this.optionFormatBuilder = Objects.requireNonNull(optionFormatBuilder,
"optionFormatBuilder");
this.comparator = Objects.requireNonNull(comparator, "comparator");
this.optionGroupSeparator = Util.defaultValue(optionGroupSeparator,
"");
@@ -107,12 +107,12 @@ public abstract class AbstractHelpFormatter {
}
/**
- * Gets the {@link HelpWriter} associated with this help formatter.
+ * Gets the {@link HelpAppendable} associated with this help formatter.
*
- * @return The {@link HelpWriter} associated with this help formatter.
+ * @return The {@link HelpAppendable} associated with this help formatter.
*/
- public final HelpWriter getSerializer() {
- return helpWriter;
+ public final HelpAppendable getSerializer() {
+ return helpAppendable;
}
/**
@@ -140,7 +140,7 @@ public abstract class AbstractHelpFormatter {
* @param options the collection of {@link Option} objects to print.
* @param footer the banner to display at the end of the help
* @param autoUsage whether to print an automatically generated usage
statement
- * @throws IOException If the output could not be written to the {@link
HelpWriter}
+ * @throws IOException If the output could not be written to the {@link
HelpAppendable}
*/
public void printHelp(final String cmdLineSyntax, final String header,
final Iterable<Option> options, final String footer, final boolean autoUsage)
throws IOException {
@@ -148,16 +148,16 @@ public abstract class AbstractHelpFormatter {
throw new IllegalArgumentException("cmdLineSyntax not provided");
}
if (autoUsage) {
- helpWriter.appendParagraph(format("%s %s %s", syntaxPrefix,
cmdLineSyntax, toSyntaxOptions(options)));
+ helpAppendable.appendParagraph(format("%s %s %s", syntaxPrefix,
cmdLineSyntax, toSyntaxOptions(options)));
} else {
- helpWriter.appendParagraph(format("%s %s", syntaxPrefix,
cmdLineSyntax));
+ helpAppendable.appendParagraph(format("%s %s", syntaxPrefix,
cmdLineSyntax));
}
if (!Util.isEmpty(header)) {
- helpWriter.appendParagraph(header);
+ helpAppendable.appendParagraph(header);
}
- helpWriter.appendTable(getTableDefinition(options));
+ helpAppendable.appendTable(getTableDefinition(options));
if (!Util.isEmpty(footer)) {
- helpWriter.appendParagraph(footer);
+ helpAppendable.appendParagraph(footer);
}
}
@@ -169,7 +169,7 @@ public abstract class AbstractHelpFormatter {
* @param options the {@link Options} to print
* @param footer the banner to display at the end of the help
* @param autoUsage whether to print an automatically generated usage
statement
- * @throws IOException If the output could not be written to the {@link
HelpWriter}
+ * @throws IOException If the output could not be written to the {@link
HelpAppendable}
*/
public final void printHelp(final String cmdLineSyntax, final String
header, final Options options, final String footer, final boolean autoUsage)
throws IOException {
@@ -177,33 +177,33 @@ public abstract class AbstractHelpFormatter {
}
/**
- * Prints the option table for a collection of {@link Option} objects to
the {@link HelpWriter}.
+ * Prints the option table for a collection of {@link Option} objects to
the {@link HelpAppendable}.
*
* @param options the collection of Option objects to print in the table.
- * @throws IOException If the output could not be written to the {@link
HelpWriter}
+ * @throws IOException If the output could not be written to the {@link
HelpAppendable}
*/
public final void printOptions(final Iterable<Option> options) throws
IOException {
printOptions(getTableDefinition(options));
}
/**
- * Prints the option table for the specified {@link Options} to the {@link
HelpWriter}.
+ * Prints the option table for the specified {@link Options} to the {@link
HelpAppendable}.
*
* @param options the Options to print in the table.
- * @throws IOException If the output could not be written to the {@link
HelpWriter}
+ * @throws IOException If the output could not be written to the {@link
HelpAppendable}
*/
public final void printOptions(final Options options) throws IOException {
printOptions(options.getOptions());
}
/**
- * Prints a {@link TableDefinition} to the {@link HelpWriter}.
+ * Prints a {@link TableDefinition} to the {@link HelpAppendable}.
*
* @param tableDefinition the {@link TableDefinition} to print.
- * @throws IOException If the output could not be written to the {@link
HelpWriter}
+ * @throws IOException If the output could not be written to the {@link
HelpAppendable}
*/
public final void printOptions(final TableDefinition tableDefinition)
throws IOException {
- helpWriter.appendTable(tableDefinition);
+ helpAppendable.appendTable(tableDefinition);
}
/**
diff --git a/src/main/java/org/apache/commons/cli/help/AbstractHelpWriter.java
b/src/main/java/org/apache/commons/cli/help/FilterHelpAppendable.java
similarity index 87%
rename from src/main/java/org/apache/commons/cli/help/AbstractHelpWriter.java
rename to src/main/java/org/apache/commons/cli/help/FilterHelpAppendable.java
index ef866c2..85c32d4 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpWriter.java
+++ b/src/main/java/org/apache/commons/cli/help/FilterHelpAppendable.java
@@ -19,11 +19,11 @@ package org.apache.commons.cli.help;
import java.io.IOException;
/**
- * An abstract implementation of {@link HelpWriter} that writes output to an
{@link Appendable} instance.
+ * An abstract implementation of {@link HelpAppendable} that writes output to
an {@link Appendable} instance.
*
* @since 1.10.0
*/
-public abstract class AbstractHelpWriter implements HelpWriter {
+public abstract class FilterHelpAppendable implements HelpAppendable {
/**
* The Appendable instance to write to.
@@ -35,7 +35,7 @@ public abstract class AbstractHelpWriter implements
HelpWriter {
*
* @param output the Appendable instance to write to.
*/
- protected AbstractHelpWriter(final Appendable output) {
+ protected FilterHelpAppendable(final Appendable output) {
this.output = output;
}
diff --git a/src/main/java/org/apache/commons/cli/help/HelpWriter.java
b/src/main/java/org/apache/commons/cli/help/HelpAppendable.java
similarity index 98%
rename from src/main/java/org/apache/commons/cli/help/HelpWriter.java
rename to src/main/java/org/apache/commons/cli/help/HelpAppendable.java
index 3355f8c..24a6b58 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpWriter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpAppendable.java
@@ -29,7 +29,7 @@ import java.util.Collection;
*
* @since 1.10.0
*/
-public interface HelpWriter extends Appendable {
+public interface HelpAppendable extends Appendable {
/**
* Appends a header.
diff --git a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
index 38b20d6..89ddb98 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -67,7 +67,7 @@ public class HelpFormatter extends AbstractHelpFormatter {
* A builder for the HelpFormatter. Intended to make more complex uses of
the HelpFormatter class easier. Default values are:
* <ul>
* <li>showSince = true</li>
- * <li>helpWriter = a {@link TextHelpWriter} writing to {@code
System.out}</li>
+ * <li>helpAppendable = a {@link TextHelpAppendable} writing to {@code
System.out}</li>
* <li>optionFormatter.Builder = the default {@link
OptionFormatter.Builder}</li>
* </ul>
*/
@@ -76,8 +76,8 @@ public class HelpFormatter extends AbstractHelpFormatter {
/** If {@code true} show the "Since" column, otherwise ignore it. */
private boolean showSince;
- /** The {@link HelpWriter} to use */
- private HelpWriter helpWriter;
+ /** The {@link HelpAppendable} to use */
+ private HelpAppendable helpAppendable;
/** The {@link OptionFormatter.Builder} to use to format options in
the table. */
private OptionFormatter.Builder optionFormatBuilder;
@@ -144,13 +144,13 @@ public class HelpFormatter extends AbstractHelpFormatter {
}
/**
- * Sets the {@link HelpWriter}.
+ * Sets the {@link HelpAppendable}.
*
- * @param helpWriter the {@link HelpWriter} to use.
+ * @param helpAppendable the {@link HelpAppendable} to use.
* @return this
*/
- public Builder setSerializer(final HelpWriter helpWriter) {
- this.helpWriter = helpWriter;
+ public Builder setSerializer(final HelpAppendable helpAppendable) {
+ this.helpAppendable = helpAppendable;
return this;
}
@@ -171,8 +171,8 @@ public class HelpFormatter extends AbstractHelpFormatter {
* @return this.
*/
private Builder validate() {
- if (helpWriter == null) {
- helpWriter = new TextHelpWriter(System.out);
+ if (helpAppendable == null) {
+ helpAppendable = new TextHelpAppendable(System.out);
}
if (optionFormatBuilder == null) {
optionFormatBuilder = new OptionFormatter.Builder();
@@ -211,18 +211,18 @@ public class HelpFormatter extends AbstractHelpFormatter {
* @param builder the Builder to build from.
*/
private HelpFormatter(final Builder builder) {
- super(builder.helpWriter, builder.optionFormatBuilder,
builder.comparator, builder.optionGroupSeparator);
+ super(builder.helpAppendable, builder.optionFormatBuilder,
builder.comparator, builder.optionGroupSeparator);
this.showSince = builder.showSince;
}
/**
- * Convenience constructor to create an instance using the specified
{@link HelpWriter} and the remaining default {@link Builder}.
+ * Convenience constructor to create an instance using the specified
{@link HelpAppendable} and the remaining default {@link Builder}.
*
- * @param helpWriter the {@link HelpWriter} to use.
+ * @param helpAppendable the {@link HelpAppendable} to use.
*/
- public HelpFormatter(final HelpWriter helpWriter) {
- this(new Builder().setSerializer(helpWriter).validate());
+ public HelpFormatter(final HelpAppendable helpAppendable) {
+ this(new Builder().setSerializer(helpAppendable).validate());
}
/**
diff --git a/src/main/java/org/apache/commons/cli/help/TextHelpWriter.java
b/src/main/java/org/apache/commons/cli/help/TextHelpAppendable.java
similarity index 98%
rename from src/main/java/org/apache/commons/cli/help/TextHelpWriter.java
rename to src/main/java/org/apache/commons/cli/help/TextHelpAppendable.java
index 23cd2c7..10e432e 100644
--- a/src/main/java/org/apache/commons/cli/help/TextHelpWriter.java
+++ b/src/main/java/org/apache/commons/cli/help/TextHelpAppendable.java
@@ -32,7 +32,7 @@ import java.util.Set;
*
* @since 1.10.0
*/
-public class TextHelpWriter extends AbstractHelpWriter {
+public class TextHelpAppendable extends FilterHelpAppendable {
/** Default number of characters per line */
public static final int DEFAULT_WIDTH = 74;
@@ -118,7 +118,7 @@ public class TextHelpWriter extends AbstractHelpWriter {
* Construct from an output.
* @param output the Appendable to write the output to.
*/
- public TextHelpWriter(final Appendable output) {
+ public TextHelpAppendable(final Appendable output) {
super(output);
styleBuilder = new TextStyle.Builder().setMaxWidth(DEFAULT_WIDTH)
.setLeftPad(DEFAULT_LEFT_PAD).setIndent(DEFAULT_INDENT);
@@ -349,7 +349,7 @@ public class TextHelpWriter extends AbstractHelpWriter {
}
/**
- * Print wrapped text using the TextHelpWriter output style.
+ * Print wrapped text using the TextHelpAppendable output style.
* @param text the text to wrap
* @throws IOException on output error.
*/
diff --git a/src/main/java/org/apache/commons/cli/help/TextStyle.java
b/src/main/java/org/apache/commons/cli/help/TextStyle.java
index 261ddea..e5ef70e 100644
--- a/src/main/java/org/apache/commons/cli/help/TextStyle.java
+++ b/src/main/java/org/apache/commons/cli/help/TextStyle.java
@@ -20,7 +20,8 @@ import java.util.function.Supplier;
/**
* The definition for styling recommendations blocks of text. Most common
usage is to style columns in a table, but may also be used to specify default
styling
- * for a {@link HelpWriter}. HelpWriters are free to ignore the TextStyle
recommendations particularly where they are not supported or contradict common
usage.
+ * for a {@link HelpAppendable}. HelpWriters are free to ignore the TextStyle
recommendations particularly where they are not supported or contradict common
+ * usage.
*
* @since 1.10.0
*/
@@ -53,7 +54,7 @@ public final class TextStyle {
/** The subsequent line indentation. */
private int indent;
- /** The scalable flag. Identifies text blocks that can be made
narrower or wider as needed by the HelpWriter. */
+ /** The scalable flag. Identifies text blocks that can be made
narrower or wider as needed by the HelpAppendable. */
private boolean scalable;
/** The minimum width. */
@@ -134,7 +135,7 @@ public final class TextStyle {
}
/**
- * Specifies if the column can be made wider or to narrower width to
fit constraints of the HelpWriter and formatting.
+ * Specifies if the column can be made wider or to narrower width to
fit constraints of the HelpAppendable and formatting.
*
* @return The currently specified scaling value.
*/
@@ -198,7 +199,7 @@ public final class TextStyle {
}
/**
- * Specifies if the column can be made wider or to narrower width to
fit constraints of the HelpWriter and formatting.
+ * Specifies if the column can be made wider or to narrower width to
fit constraints of the HelpAppendable and formatting.
*
* @param scalable if {@code true} the text width can be adjusted.
* @return this.
@@ -295,7 +296,7 @@ public final class TextStyle {
}
/**
- * Specifies if the column can be made wider or to narrower width to fit
constraints of the HelpWriter and formatting.
+ * Specifies if the column can be made wider or to narrower width to fit
constraints of the HelpAppendable and formatting.
*
* @return the scaling value.
*/
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 f70ff8a..3e44f18 100644
--- a/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java
+++ b/src/test/java/org/apache/commons/cli/help/HelpFormatterTest.java
@@ -29,7 +29,7 @@ import java.util.List;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
-import org.apache.commons.example.cli.XhtmlHelpWriter;
+import org.apache.commons.example.cli.XhtmlHelpAppendable;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
@@ -59,9 +59,9 @@ public class HelpFormatterTest {
@Test
public void testDefault() {
final StringBuilder sb = new StringBuilder();
- final TextHelpWriter serializer = new TextHelpWriter(sb);
+ final TextHelpAppendable serializer = new TextHelpAppendable(sb);
final HelpFormatter formatter = new HelpFormatter(serializer);
- assertEquals(serializer, formatter.getSerializer(), "Unexpected
helpWriter tests may fail unexpectedly");
+ assertEquals(serializer, formatter.getSerializer(), "Unexpected
helpAppendable tests may fail unexpectedly");
assertEquals(AbstractHelpFormatter.DEFAULT_COMPARATOR,
formatter.getComparator(), "Unexpected comparator tests may fail unexpectedly");
assertEquals(AbstractHelpFormatter.DEFAULT_SYNTAX_PREFIX,
formatter.getSyntaxPrefix(), "Unexpected syntax prefix tests may fail
unexpectedly");
}
@@ -69,7 +69,7 @@ public class HelpFormatterTest {
@Test
public void testPrintHelp() throws IOException {
final StringBuilder sb = new StringBuilder();
- final TextHelpWriter serializer = new TextHelpWriter(sb);
+ final TextHelpAppendable serializer = new TextHelpAppendable(sb);
HelpFormatter formatter = new HelpFormatter(serializer);
final Options options = new
Options().addOption(Option.builder("a").since("1853").hasArg().desc("aaaa aaaa
aaaa aaaa aaaa").build());
@@ -147,7 +147,7 @@ public class HelpFormatterTest {
@Test
public void testPrintHelpXML() throws IOException {
final StringBuilder sb = new StringBuilder();
- final XhtmlHelpWriter serializer = new XhtmlHelpWriter(sb);
+ final XhtmlHelpAppendable serializer = new XhtmlHelpAppendable(sb);
final HelpFormatter formatter = new HelpFormatter(serializer);
final Options options = new Options().addOption("a", false, "aaaa aaaa
aaaa aaaa aaaa");
@@ -178,16 +178,16 @@ public class HelpFormatterTest {
@Test
public void testPrintOptions() throws IOException {
final StringBuilder sb = new StringBuilder();
- final TextHelpWriter serializer = new TextHelpWriter(sb);
+ final TextHelpAppendable serializer = new TextHelpAppendable(sb);
final HelpFormatter formatter = new
HelpFormatter.Builder().setSerializer(serializer).setShowSince(false).build();
// help format default column styles
- // col options description helpWriter
+ // col options description helpAppendable
// styl FIXED VARIABLE VARIABLE
// LPad 0 5 1
// indent 1 1 3
//
- // default helpWriter
+ // default helpAppendable
Options options;
List<String> expected = new ArrayList<>();
@@ -292,7 +292,7 @@ public class HelpFormatterTest {
@Test
public void testSyntaxPrefix() {
final StringBuilder sb = new StringBuilder();
- final TextHelpWriter serializer = new TextHelpWriter(sb);
+ final TextHelpAppendable serializer = new TextHelpAppendable(sb);
final HelpFormatter formatter = new HelpFormatter(serializer);
formatter.setSyntaxPrefix("Something new");
assertEquals("Something new", formatter.getSyntaxPrefix());
@@ -302,7 +302,7 @@ public class HelpFormatterTest {
@Test
public void testToArgNameTest() {
final StringBuilder sb = new StringBuilder();
- final TextHelpWriter serializer = new TextHelpWriter(sb);
+ final TextHelpAppendable serializer = new TextHelpAppendable(sb);
final HelpFormatter formatter = new HelpFormatter(serializer);
assertEquals("<some Arg>", formatter.toArgName("some Arg"));
diff --git a/src/test/java/org/apache/commons/cli/help/TextHelpWriterTest.java
b/src/test/java/org/apache/commons/cli/help/TextHelpWriterTest.java
index bf4dfd6..f5f6d6f 100644
--- a/src/test/java/org/apache/commons/cli/help/TextHelpWriterTest.java
+++ b/src/test/java/org/apache/commons/cli/help/TextHelpWriterTest.java
@@ -38,12 +38,12 @@ import org.junit.jupiter.params.provider.MethodSource;
public final class TextHelpWriterTest {
private StringBuilder sb;
- private TextHelpWriter underTest;
+ private TextHelpAppendable underTest;
@BeforeEach
public void setUp() {
sb = new StringBuilder();
- underTest = new TextHelpWriter(sb);
+ underTest = new TextHelpAppendable(sb);
}
@Test
@@ -299,30 +299,30 @@ public final class TextHelpWriterTest {
public void testFindWrapPos() {
final String testString = "The quick brown fox jumps over\tthe lazy
dog";
- assertEquals(9, TextHelpWriter.findWrapPos(testString, 10, 0), "did
not find end of word");
- assertEquals(9, TextHelpWriter.findWrapPos(testString, 14, 0), "did
not backup to end of word");
- assertEquals(15, TextHelpWriter.findWrapPos(testString, 15, 0), "did
not find word at 15");
- assertEquals(15, TextHelpWriter.findWrapPos(testString, 16, 0));
- assertEquals(30, TextHelpWriter.findWrapPos(testString, 15, 20), "did
not find break character");
- assertEquals(30, TextHelpWriter.findWrapPos(testString, 150, 0), "did
not handle text shorter than width");
+ assertEquals(9, TextHelpAppendable.findWrapPos(testString, 10, 0),
"did not find end of word");
+ assertEquals(9, TextHelpAppendable.findWrapPos(testString, 14, 0),
"did not backup to end of word");
+ assertEquals(15, TextHelpAppendable.findWrapPos(testString, 15, 0),
"did not find word at 15");
+ assertEquals(15, TextHelpAppendable.findWrapPos(testString, 16, 0));
+ assertEquals(30, TextHelpAppendable.findWrapPos(testString, 15, 20),
"did not find break character");
+ assertEquals(30, TextHelpAppendable.findWrapPos(testString, 150, 0),
"did not handle text shorter than width");
- assertThrows(IllegalArgumentException.class, () ->
TextHelpWriter.findWrapPos("", 0, 0));
- assertEquals(3, TextHelpWriter.findWrapPos("Hello", 4, 0));
+ assertThrows(IllegalArgumentException.class, () ->
TextHelpAppendable.findWrapPos("", 0, 0));
+ assertEquals(3, TextHelpAppendable.findWrapPos("Hello", 4, 0));
}
@ParameterizedTest
@MethodSource("org.apache.commons.cli.help.UtilTest#charArgs")
public void testFindWrapPosWithWhitespace(final Character c, final boolean
isWhitespace) {
final String text = format("Hello%cWorld", c);
- assertEquals(isWhitespace ? 5 : 6, TextHelpWriter.findWrapPos(text, 7,
0));
+ assertEquals(isWhitespace ? 5 : 6,
TextHelpAppendable.findWrapPos(text, 7, 0));
}
@Test
public void testGetStyleBuilder() {
final TextStyle.Builder builder = underTest.getStyleBuilder();
- assertEquals(TextHelpWriter.DEFAULT_INDENT, builder.getIndent(),
"Default indent value was changed, some tests may fail");
- assertEquals(TextHelpWriter.DEFAULT_LEFT_PAD, builder.getLeftPad(),
"Default left pad value was changed, some tests may fail");
- assertEquals(TextHelpWriter.DEFAULT_WIDTH, builder.getMaxWidth(),
"Default width value was changed, some tests may fail");
+ assertEquals(TextHelpAppendable.DEFAULT_INDENT, builder.getIndent(),
"Default indent value was changed, some tests may fail");
+ assertEquals(TextHelpAppendable.DEFAULT_LEFT_PAD,
builder.getLeftPad(), "Default left pad value was changed, some tests may
fail");
+ assertEquals(TextHelpAppendable.DEFAULT_WIDTH, builder.getMaxWidth(),
"Default width value was changed, some tests may fail");
}
@Test
@@ -412,9 +412,9 @@ public final class TextHelpWriterTest {
@Test
public void testSetIndent() {
- assertEquals(TextHelpWriter.DEFAULT_INDENT, underTest.getIndent(),
"Default indent value was changed, some tests may fail");
- underTest.setIndent(TextHelpWriter.DEFAULT_INDENT + 2);
- assertEquals(underTest.getIndent(), TextHelpWriter.DEFAULT_INDENT + 2);
+ assertEquals(TextHelpAppendable.DEFAULT_INDENT, underTest.getIndent(),
"Default indent value was changed, some tests may fail");
+ underTest.setIndent(TextHelpAppendable.DEFAULT_INDENT + 2);
+ assertEquals(underTest.getIndent(), TextHelpAppendable.DEFAULT_INDENT
+ 2);
}
@Test
diff --git a/src/test/java/org/apache/commons/example/cli/AptHelpWriter.java
b/src/test/java/org/apache/commons/example/cli/AptHelpAppendable.java
similarity index 97%
rename from src/test/java/org/apache/commons/example/cli/AptHelpWriter.java
rename to src/test/java/org/apache/commons/example/cli/AptHelpAppendable.java
index e6a039a..463e416 100644
--- a/src/test/java/org/apache/commons/example/cli/AptHelpWriter.java
+++ b/src/test/java/org/apache/commons/example/cli/AptHelpAppendable.java
@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.cli.help.AbstractHelpWriter;
+import org.apache.commons.cli.help.FilterHelpAppendable;
import org.apache.commons.cli.help.TableDefinition;
import org.apache.commons.cli.help.TextStyle;
import org.apache.commons.lang3.StringUtils;
@@ -34,7 +34,7 @@ import org.apache.commons.text.translate.LookupTranslator;
/**
* A class to write APT formatted text.
*/
-public class AptHelpWriter extends AbstractHelpWriter {
+public class AptHelpAppendable extends FilterHelpAppendable {
/**
* Translator object for escaping APT codes
@@ -65,7 +65,7 @@ public class AptHelpWriter extends AbstractHelpWriter {
return new String(padding);
}
- public AptHelpWriter(final Appendable output) {
+ public AptHelpAppendable(final Appendable output) {
super(output);
}
diff --git
a/src/test/java/org/apache/commons/example/cli/AptHelpWriterTest.java
b/src/test/java/org/apache/commons/example/cli/AptHelpWriterTest.java
index 6af883d..5e74bea 100644
--- a/src/test/java/org/apache/commons/example/cli/AptHelpWriterTest.java
+++ b/src/test/java/org/apache/commons/example/cli/AptHelpWriterTest.java
@@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
public class AptHelpWriterTest {
private final StringBuilder sb = new StringBuilder();
- private final AptHelpWriter underTest = new AptHelpWriter(sb);
+ private final AptHelpAppendable underTest = new AptHelpAppendable(sb);
@Test
public void testAppendHeaderTest() throws IOException {
diff --git a/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriter.java
b/src/test/java/org/apache/commons/example/cli/XhtmlHelpAppendable.java
similarity index 94%
rename from src/test/java/org/apache/commons/example/cli/XhtmlHelpWriter.java
rename to src/test/java/org/apache/commons/example/cli/XhtmlHelpAppendable.java
index 0a7fc81..5b1a843 100644
--- a/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriter.java
+++ b/src/test/java/org/apache/commons/example/cli/XhtmlHelpAppendable.java
@@ -22,15 +22,15 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
-import org.apache.commons.cli.help.AbstractHelpWriter;
+import org.apache.commons.cli.help.FilterHelpAppendable;
import org.apache.commons.cli.help.TableDefinition;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
-/** An example XML helpWriter */
-public class XhtmlHelpWriter extends AbstractHelpWriter {
+/** An example XML helpAppendable */
+public class XhtmlHelpAppendable extends FilterHelpAppendable {
- public XhtmlHelpWriter(final Appendable output) {
+ public XhtmlHelpAppendable(final Appendable output) {
super(output);
}
diff --git
a/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriterTest.java
b/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriterTest.java
index 6421ee9..7a4c4a7 100644
--- a/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriterTest.java
+++ b/src/test/java/org/apache/commons/example/cli/XhtmlHelpWriterTest.java
@@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
public class XhtmlHelpWriterTest {
private final StringBuilder sb = new StringBuilder();
- private final XhtmlHelpWriter underTest = new XhtmlHelpWriter(sb);
+ private final XhtmlHelpAppendable underTest = new XhtmlHelpAppendable(sb);
@Test
public void testAppendHeaderTest() throws IOException {