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
The following commit(s) were added to refs/heads/master by this push:
new ca6d3362 Internal refactoring
ca6d3362 is described below
commit ca6d3362c46ef0f94bc10d92efaae8d3c93efc42
Author: Gary Gregory <[email protected]>
AuthorDate: Sat May 16 11:48:33 2026 +0000
Internal refactoring
---
.../org/apache/commons/cli/help/HelpFormatter.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
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 f0723706..c9d5080b 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -18,7 +18,6 @@
package org.apache.commons.cli.help;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.apache.commons.cli.Option;
@@ -62,6 +61,21 @@ import org.apache.commons.cli.Option;
*/
public class HelpFormatter extends AbstractHelpFormatter {
+ /**
+ * The default "Since" column label.
+ */
+ private static final String LABEL_SINCE = "Since";
+
+ /**
+ * The default "Description" column label.
+ */
+ private static final String LABEL_DESCRIPTION = "Description";
+
+ /**
+ * The default "Options" column label.
+ */
+ private static final String LABEL_OPTIONS = "Options";
+
/**
* A builder for the HelpFormatter. Intended to make more complex uses of
the HelpFormatter class easier. Default values are:
* <ul>
@@ -184,6 +198,12 @@ public class HelpFormatter extends AbstractHelpFormatter {
rows.add(row);
});
// return the TableDefinition with the proper column headers.
- return TableDefinition.from("", styles, showSince ?
Arrays.asList("Options", "Since", "Description") : Arrays.asList("Options",
"Description"), rows);
+ List<String> headers = new ArrayList<>(3);
+ headers.add(LABEL_OPTIONS);
+ if (showSince) {
+ headers.add(LABEL_SINCE);
+ }
+ headers.add(LABEL_DESCRIPTION);
+ return TableDefinition.from("", styles, headers, rows);
}
}