You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/10/18 14:04:50 UTC

(commons-cli) branch master updated (9f5a4d99 -> ab04dd1b)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-cli.git


    from 9f5a4d99 Make XHTML example more null-safe
     new ef11f175 Make org.apache.commons.cli.help.AbstractHelpFormatter.comparator final
     new 6ce3fa3e Add missing @Override
     new ccebe902 Encapsulate new fields
     new ab04dd1b Javadoc

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/commons/cli/DefaultParser.java |  1 +
 .../commons/cli/help/AbstractHelpFormatter.java    | 45 +++++++++++++++++-----
 .../org/apache/commons/cli/help/HelpFormatter.java |  4 +-
 .../apache/commons/cli/help/OptionFormatter.java   |  8 ++--
 .../org/apache/commons/cli/help/TextStyle.java     |  2 +-
 5 files changed, 44 insertions(+), 16 deletions(-)


(commons-cli) 04/04: Javadoc

Posted by gg...@apache.org.
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

commit ab04dd1b856765de690ccd0717280b6bd34925d3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 18 10:04:45 2024 -0400

    Javadoc
---
 src/main/java/org/apache/commons/cli/help/HelpFormatter.java   | 2 +-
 src/main/java/org/apache/commons/cli/help/OptionFormatter.java | 8 ++++----
 src/main/java/org/apache/commons/cli/help/TextStyle.java       | 2 +-
 3 files changed, 6 insertions(+), 6 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 4eb35314..63cf4059 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -94,7 +94,7 @@ public class HelpFormatter extends AbstractHelpFormatter {
          * Sets the showSince flag.
          *
          * @param showSince the desired value of the showSince flag.
-         * @return this.
+         * @return this instance.
          */
         public Builder setShowSince(final boolean showSince) {
             this.showSince = showSince;
diff --git a/src/main/java/org/apache/commons/cli/help/OptionFormatter.java b/src/main/java/org/apache/commons/cli/help/OptionFormatter.java
index 1755dd93..5cba55ff 100644
--- a/src/main/java/org/apache/commons/cli/help/OptionFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/OptionFormatter.java
@@ -114,7 +114,7 @@ public final class OptionFormatter {
          *
          * @param begin the beginning delimiter.
          * @param end   the ending delimiter.
-         * @return this.
+         * @return this instance.
          */
         public Builder setArgumentNameDelimiters(final String begin, final String end) {
             this.argNameDelimiters[0] = Util.defaultValue(begin, "");
@@ -137,7 +137,7 @@ public final class OptionFormatter {
          * Specifies the function to construct the deprecated massage for the Option. Should include the description text if desired.
          *
          * @param deprecatedFormatFunction the function to specify the deprecated message for the option.
-         * @return this.
+         * @return this instance.
          */
         public Builder setDeprecatedFormatFunction(final Function<Option, String> deprecatedFormatFunction) {
             this.deprecatedFormatFunction = deprecatedFormatFunction;
@@ -172,7 +172,7 @@ public final class OptionFormatter {
          *
          * @param begin the beginning delimiter.
          * @param end   the ending delimiter.
-         * @return this.
+         * @return this instance.
          */
         public Builder setOptionalDelimiters(final String begin, final String end) {
             this.optionalDelimiters[0] = Util.defaultValue(begin, "");
@@ -184,7 +184,7 @@ public final class OptionFormatter {
          * Specifies the short option prefix.
          *
          * @param optPrefix the prefix for short options.
-         * @return this.
+         * @return this instance.
          */
         public Builder setOptPrefix(final String optPrefix) {
             this.optPrefix = Util.defaultValue(optPrefix, "");
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 b3ca3121..32a69071 100644
--- a/src/main/java/org/apache/commons/cli/help/TextStyle.java
+++ b/src/main/java/org/apache/commons/cli/help/TextStyle.java
@@ -200,7 +200,7 @@ public final class TextStyle {
          * Sets whether the column can be made wider or to narrower width to fit constraints of the HelpAppendable and formatting.
          *
          * @param scalable Whether the text width can be adjusted.
-         * @return this.
+         * @return this instance.
          */
         public Builder setScalable(final boolean scalable) {
             this.scalable = scalable;


(commons-cli) 03/04: Encapsulate new fields

Posted by gg...@apache.org.
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

commit ccebe9023819f3be431bf7cacbcf27321fbefe70
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 18 10:03:04 2024 -0400

    Encapsulate new fields
    
    Javadoc
---
 .../commons/cli/help/AbstractHelpFormatter.java    | 45 +++++++++++++++++-----
 .../org/apache/commons/cli/help/HelpFormatter.java |  2 +-
 2 files changed, 37 insertions(+), 10 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 c62521eb..d5e5ee62 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
@@ -63,7 +63,7 @@ public abstract class AbstractHelpFormatter {
         private String optionGroupSeparator = DEFAULT_OPTION_GROUP_SEPARATOR;
 
         /**
-         * Constructs a new instace.
+         * Constructs a new instance.
          * <p>
          * Sets {@code showSince} to {@code true}.
          * </p>
@@ -180,24 +180,24 @@ public abstract class AbstractHelpFormatter {
     public static final String DEFAULT_SYNTAX_PREFIX = "usage: ";
 
     /** The comparator for sorting {@link Option} collections */
-    protected final Comparator<Option> comparator;
+    private final Comparator<Option> comparator;
     /**
      * The {@link HelpAppendable} that produces the final output.
      */
-    protected final HelpAppendable helpAppendable;
+    private final HelpAppendable helpAppendable;
 
     /**
      * The OptionFormatter.Builder used to display options within the help page
      */
-    protected final OptionFormatter.Builder optionFormatBuilder;
+    private final OptionFormatter.Builder optionFormatBuilder;
 
     /** The separator between {@link OptionGroup} components. */
-    protected final String optionGroupSeparator;
+    private final String optionGroupSeparator;
 
     /**
      * The phrase printed before the syntax line.
      */
-    protected String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
+    private String syntaxPrefix = DEFAULT_SYNTAX_PREFIX;
 
     /**
      * Constructs the base formatter.
@@ -212,14 +212,32 @@ public abstract class AbstractHelpFormatter {
     }
 
     /**
-     * Gets the comparator used by this HelpFormatter.
+     * Gets the comparator for sorting options.
      *
-     * @return The comparator used by this HelpFormatter.
+     * @return The comparator for sorting options.
      */
-    public Comparator<Option> getComparator() {
+    protected Comparator<Option> getComparator() {
         return comparator;
     }
 
+    /**
+     * Gets the help appendable.
+     *
+     * @return The help appendable.
+     */
+    protected HelpAppendable getHelpAppendable() {
+        return helpAppendable;
+    }
+
+    /**
+     * Gets the option formatter builder.
+     *
+     * @return The option formatter builder.
+     */
+    protected OptionFormatter.Builder getOptionFormatBuilder() {
+        return optionFormatBuilder;
+    }
+
     /**
      * Constructs an {@link OptionFormatter} for the specified {@link Option}.
      *
@@ -230,6 +248,15 @@ public abstract class AbstractHelpFormatter {
         return optionFormatBuilder.build(option);
     }
 
+    /**
+     * Gets the option group separator.
+     *
+     * @return The option group separator.
+     */
+    protected String getOptionGroupSeparator() {
+        return optionGroupSeparator;
+    }
+
     /**
      * Gets the {@link HelpAppendable} associated with this help formatter.
      *
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 86efe246..4eb35314 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -166,7 +166,7 @@ public class HelpFormatter extends AbstractHelpFormatter {
         for (final Option option : options) {
             final List<String> row = new ArrayList<>();
             // create an option formatter to correctly format the parts of the option
-            final OptionFormatter formatter = optionFormatBuilder.build(option);
+            final OptionFormatter formatter = getOptionFormatBuilder().build(option);
             sb.setLength(0);
             // append the opt values.
             sb.append(formatter.getBothOpt());


(commons-cli) 01/04: Make org.apache.commons.cli.help.AbstractHelpFormatter.comparator final

Posted by gg...@apache.org.
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

commit ef11f175aba987b4396b14bb7518870d6b048c8d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 18 09:57:03 2024 -0400

    Make org.apache.commons.cli.help.AbstractHelpFormatter.comparator final
---
 src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 71b69ab3..c62521eb 100644
--- a/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/AbstractHelpFormatter.java
@@ -180,7 +180,7 @@ public abstract class AbstractHelpFormatter {
     public static final String DEFAULT_SYNTAX_PREFIX = "usage: ";
 
     /** The comparator for sorting {@link Option} collections */
-    protected Comparator<Option> comparator;
+    protected final Comparator<Option> comparator;
     /**
      * The {@link HelpAppendable} that produces the final output.
      */


(commons-cli) 02/04: Add missing @Override

Posted by gg...@apache.org.
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

commit 6ce3fa3e0fd74ea60b6d663be240255e089056e3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Oct 18 09:57:12 2024 -0400

    Add missing @Override
---
 src/main/java/org/apache/commons/cli/DefaultParser.java | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/main/java/org/apache/commons/cli/DefaultParser.java b/src/main/java/org/apache/commons/cli/DefaultParser.java
index 7b88a7da..52090384 100644
--- a/src/main/java/org/apache/commons/cli/DefaultParser.java
+++ b/src/main/java/org/apache/commons/cli/DefaultParser.java
@@ -88,6 +88,7 @@ public class DefaultParser implements CommandLineParser {
          * @return the new {@link DefaultParser}
          * @since 1.10.0
          */
+        @Override
         public DefaultParser get() {
             return new DefaultParser(allowPartialMatching, stripLeadingAndTrailingQuotes, deprecatedHandler);
         }