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 f5931a51ef761a1276dfc559573c6ef63a1a4579
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Nov 29 08:26:39 2024 -0500

    Better parameter names
---
 .../java/org/apache/commons/cli/CommandLine.java   | 188 ++++++++++-----------
 1 file changed, 94 insertions(+), 94 deletions(-)

diff --git a/src/main/java/org/apache/commons/cli/CommandLine.java 
b/src/main/java/org/apache/commons/cli/CommandLine.java
index 155aaab2..abea5441 100644
--- a/src/main/java/org/apache/commons/cli/CommandLine.java
+++ b/src/main/java/org/apache/commons/cli/CommandLine.java
@@ -31,8 +31,8 @@ import java.util.function.Supplier;
 /**
  * Represents list of arguments parsed against a {@link Options} descriptor.
  * <p>
- * It allows querying of a boolean {@link #hasOption(String opt)}, in addition 
to retrieving the
- * {@link #getOptionValue(String opt)} for options requiring arguments.
+ * It allows querying of a boolean {@link #hasOption(String optionName)}, in 
addition to retrieving the
+ * {@link #getOptionValue(String optionName)} for options requiring arguments.
  * </p>
  * <p>
  * Additionally, any left-over or unrecognized arguments, are available for 
further processing.
@@ -89,12 +89,12 @@ public class CommandLine implements Serializable {
         /**
          * Adds an option to the command line. The values of the option are 
stored.
          *
-         * @param opt the processed option.
+         * @param option the processed option.
          * @return this Builder instance for method chaining.
          */
-        public Builder addOption(final Option opt) {
-            if (opt != null) {
-                options.add(opt);
+        public Builder addOption(final Option option) {
+            if (option != null) {
+                options.add(option);
             }
             return this;
         }
@@ -191,11 +191,11 @@ public class CommandLine implements Serializable {
     /**
      * Adds an option to the command line. The values of the option are stored.
      *
-     * @param opt the processed option.
+     * @param option the processed option.
      */
-    protected void addOption(final Option opt) {
-        if (opt != null) {
-            options.add(opt);
+    protected void addOption(final Option option) {
+        if (option != null) {
+            options.add(option);
         }
     }
 
@@ -225,27 +225,27 @@ public class CommandLine implements Serializable {
      * Gets the {@code Object} type of this {@code Option}.
      *
      * @deprecated due to System.err message. Instead use 
getParsedOptionValue(char)
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @return the type of opt.
      */
     @Deprecated
-    public Object getOptionObject(final char opt) {
-        return getOptionObject(String.valueOf(opt));
+    public Object getOptionObject(final char optionChar) {
+        return getOptionObject(String.valueOf(optionChar));
     }
 
     /**
      * Gets the {@code Object} type of this {@code Option}.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @return the type of this {@code Option}.
      * @deprecated due to System.err message. Instead use 
getParsedOptionValue(String)
      */
     @Deprecated
-    public Object getOptionObject(final String opt) {
+    public Object getOptionObject(final String optionName) {
         try {
-            return getParsedOptionValue(opt);
+            return getParsedOptionValue(optionName);
         } catch (final ParseException pe) {
-            System.err.println("Exception found converting " + opt + " to 
desired type: " + pe.getMessage());
+            System.err.println("Exception found converting " + optionName + " 
to desired type: " + pe.getMessage());
             return null;
         }
     }
@@ -277,14 +277,14 @@ public class CommandLine implements Serializable {
      * -Dparam2=value2</code>. The first argument of the option is the key, 
and the 2nd argument is the value. If the option
      * has only one argument ({@code -Dfoo}) it is considered as a boolean 
flag and the value is {@code "true"}.
      *
-     * @param opt name of the option.
+     * @param optionName name of the option.
      * @return The Properties mapped by the option, never {@code null} even if 
the option doesn't exists.
      * @since 1.2
      */
-    public Properties getOptionProperties(final String opt) {
+    public Properties getOptionProperties(final String optionName) {
         final Properties props = new Properties();
         for (final Option option : options) {
-            if (opt.equals(option.getOpt()) || 
opt.equals(option.getLongOpt())) {
+            if (optionName.equals(option.getOpt()) || 
optionName.equals(option.getLongOpt())) {
                 processPropertiesFromValues(props, option.getValuesList());
             }
         }
@@ -303,34 +303,34 @@ public class CommandLine implements Serializable {
     /**
      * Gets the first argument, if any, of this option.
      *
-     * @param opt the character name of the option.
+     * @param optionChar the character name of the option.
      * @return Value of the argument if option is set, and has an argument, 
otherwise null.
      */
-    public String getOptionValue(final char opt) {
-        return getOptionValue(String.valueOf(opt));
+    public String getOptionValue(final char optionChar) {
+        return getOptionValue(String.valueOf(optionChar));
     }
 
     /**
      * Gets the argument, if any, of an option.
      *
-     * @param opt character name of the option
+     * @param optionChar character name of the option
      * @param defaultValue is the default value to be returned if the option 
is not specified.
      * @return Value of the argument if option is set, and has an argument, 
otherwise {@code defaultValue}.
      */
-    public String getOptionValue(final char opt, final String defaultValue) {
-        return getOptionValue(String.valueOf(opt), () -> defaultValue);
+    public String getOptionValue(final char optionChar, final String 
defaultValue) {
+        return getOptionValue(String.valueOf(optionChar), () -> defaultValue);
     }
 
     /**
      * Gets the argument, if any, of an option.
      *
-     * @param opt character name of the option
+     * @param optionChar character name of the option
      * @param defaultValue is a supplier for the default value to be returned 
if the option is not specified.
      * @return Value of the argument if option is set, and has an argument, 
otherwise {@code defaultValue}.
      * @since 1.7.0
      */
-    public String getOptionValue(final char opt, final Supplier<String> 
defaultValue) {
-        return getOptionValue(String.valueOf(opt), defaultValue);
+    public String getOptionValue(final char optionChar, final Supplier<String> 
defaultValue) {
+        return getOptionValue(String.valueOf(optionChar), defaultValue);
     }
 
     /**
@@ -411,45 +411,45 @@ public class CommandLine implements Serializable {
     /**
      * Gets the first argument, if any, of this option.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @return Value of the argument if option is set, and has an argument, 
otherwise null.
      */
-    public String getOptionValue(final String opt) {
-        return getOptionValue(resolveOption(opt));
+    public String getOptionValue(final String optionName) {
+        return getOptionValue(resolveOption(optionName));
     }
 
     /**
      * Gets the first argument, if any, of an option.
      *
-     * @param opt name of the option.
+     * @param optionName name of the option.
      * @param defaultValue is the default value to be returned if the option 
is not specified.
      * @return Value of the argument if option is set, and has an argument, 
otherwise {@code defaultValue}.
      */
-    public String getOptionValue(final String opt, final String defaultValue) {
-        return getOptionValue(resolveOption(opt), () -> defaultValue);
+    public String getOptionValue(final String optionName, final String 
defaultValue) {
+        return getOptionValue(resolveOption(optionName), () -> defaultValue);
     }
 
     /**
      * Gets the first argument, if any, of an option.
      *
-     * @param opt name of the option.
+     * @param optionName name of the option.
      * @param defaultValue is a supplier for the default value to be returned 
if the option is not specified.
      * @return Value of the argument if option is set, and has an argument, 
otherwise {@code defaultValue}.
      * @since 1.7.0
      */
-    public String getOptionValue(final String opt, final Supplier<String> 
defaultValue) {
-        return getOptionValue(resolveOption(opt), defaultValue);
+    public String getOptionValue(final String optionName, final 
Supplier<String> defaultValue) {
+        return getOptionValue(resolveOption(optionName), defaultValue);
     }
 
 
     /**
      * Gets the array of values, if any, of an option.
      *
-     * @param opt character name of the option.
+     * @param optionChar character name of the option.
      * @return Values of the argument if option is set, and has an argument, 
otherwise null.
      */
-    public String[] getOptionValues(final char opt) {
-        return getOptionValues(String.valueOf(opt));
+    public String[] getOptionValues(final char optionChar) {
+        return getOptionValues(String.valueOf(optionChar));
     }
 
     /**
@@ -492,31 +492,31 @@ public class CommandLine implements Serializable {
     /**
      * Gets the array of values, if any, of an option.
      *
-     * @param opt string name of the option.
+     * @param optionName string name of the option.
      * @return Values of the argument if option is set, and has an argument, 
otherwise null.
      */
-    public String[] getOptionValues(final String opt) {
-        return getOptionValues(resolveOption(opt));
+    public String[] getOptionValues(final String optionName) {
+        return getOptionValues(resolveOption(optionName));
     }
 
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or null if the option 
is not set.
      * @throws ParseException if there are problems turning the option value 
into the desired type
      * @see PatternOptionBuilder
      * @since 1.5.0
      */
-    public <T> T getParsedOptionValue(final char opt) throws ParseException {
-        return getParsedOptionValue(String.valueOf(opt));
+    public <T> T getParsedOptionValue(final char optionChar) throws 
ParseException {
+        return getParsedOptionValue(String.valueOf(optionChar));
     }
 
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or the defaultValue 
if the option is not set.
@@ -524,14 +524,14 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.7.0
      */
-    public <T> T getParsedOptionValue(final char opt, final Supplier<T> 
defaultValue) throws ParseException {
-        return getParsedOptionValue(String.valueOf(opt), defaultValue);
+    public <T> T getParsedOptionValue(final char optionChar, final Supplier<T> 
defaultValue) throws ParseException {
+        return getParsedOptionValue(String.valueOf(optionChar), defaultValue);
     }
 
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or the defaultValue 
if the option is not set.
@@ -539,8 +539,8 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.7.0
      */
-    public <T> T getParsedOptionValue(final char opt, final T defaultValue) 
throws ParseException {
-        return getParsedOptionValue(String.valueOf(opt), defaultValue);
+    public <T> T getParsedOptionValue(final char optionChar, final T 
defaultValue) throws ParseException {
+        return getParsedOptionValue(String.valueOf(optionChar), defaultValue);
     }
 
     /**
@@ -649,21 +649,21 @@ public class CommandLine implements Serializable {
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or null if the option 
is not set.
      * @throws ParseException if there are problems turning the option value 
into the desired type
      * @see PatternOptionBuilder
      * @since 1.2
      */
-    public <T> T getParsedOptionValue(final String opt) throws ParseException {
-        return getParsedOptionValue(resolveOption(opt));
+    public <T> T getParsedOptionValue(final String optionName) throws 
ParseException {
+        return getParsedOptionValue(resolveOption(optionName));
     }
 
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or the defaultValue 
if the option is not set.
@@ -671,14 +671,14 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.7.0
      */
-    public <T> T getParsedOptionValue(final String opt, final Supplier<T> 
defaultValue) throws ParseException {
-        return getParsedOptionValue(resolveOption(opt), defaultValue);
+    public <T> T getParsedOptionValue(final String optionName, final 
Supplier<T> defaultValue) throws ParseException {
+        return getParsedOptionValue(resolveOption(optionName), defaultValue);
     }
 
     /**
      * Gets a version of this {@code Option} converted to a particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The return type for the method.
      * @return the value parsed into a particular object or the defaultValue 
if the option is not set.
@@ -686,28 +686,28 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.7.0
      */
-    public <T> T getParsedOptionValue(final String opt, final T defaultValue) 
throws ParseException {
-        return getParsedOptionValue(resolveOption(opt), defaultValue);
+    public <T> T getParsedOptionValue(final String optionName, final T 
defaultValue) throws ParseException {
+        return getParsedOptionValue(resolveOption(optionName), defaultValue);
     }
 
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or null if the 
option is not set.
      * @throws ParseException if there are problems turning the option value 
into the desired type
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final char opt) throws ParseException 
{
-        return getParsedOptionValues(String.valueOf(opt));
+    public <T> T[] getParsedOptionValues(final char optionChar) throws 
ParseException {
+        return getParsedOptionValues(String.valueOf(optionChar));
     }
 
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or the defaultValue 
if the option is not set.
@@ -715,14 +715,14 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final char opt, final Supplier<T[]> 
defaultValue) throws ParseException {
-        return getParsedOptionValues(String.valueOf(opt), defaultValue);
+    public <T> T[] getParsedOptionValues(final char optionChar, final 
Supplier<T[]> defaultValue) throws ParseException {
+        return getParsedOptionValues(String.valueOf(optionChar), defaultValue);
     }
 
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionChar the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or the defaultValue 
if the option is not set.
@@ -730,8 +730,8 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final char opt, final T[] 
defaultValue) throws ParseException {
-        return getParsedOptionValues(String.valueOf(opt), defaultValue);
+    public <T> T[] getParsedOptionValues(final char optionChar, final T[] 
defaultValue) throws ParseException {
+        return getParsedOptionValues(String.valueOf(optionChar), defaultValue);
     }
 
     /**
@@ -845,21 +845,21 @@ public class CommandLine implements Serializable {
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or null if the 
option is not set.
      * @throws ParseException if there are problems turning the option value 
into the desired type
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final String opt) throws 
ParseException {
-        return getParsedOptionValues(resolveOption(opt));
+    public <T> T[] getParsedOptionValues(final String optionName) throws 
ParseException {
+        return getParsedOptionValues(resolveOption(optionName));
     }
 
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or defaultValues if 
the option is not set.
@@ -867,14 +867,14 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final String opt, final Supplier<T[]> 
defaultValue) throws ParseException {
-        return getParsedOptionValues(resolveOption(opt), defaultValue);
+    public <T> T[] getParsedOptionValues(final String optionName, final 
Supplier<T[]> defaultValue) throws ParseException {
+        return getParsedOptionValues(resolveOption(optionName), defaultValue);
     }
 
     /**
      * Gets a version of this {@code Option} converted to an array of a 
particular type.
      *
-     * @param opt the name of the option.
+     * @param optionName the name of the option.
      * @param defaultValue the default value to return if opt is not set.
      * @param <T> The array type for the return value.
      * @return the values parsed into an array of objects or defaultValues if 
the option is not set.
@@ -882,8 +882,8 @@ public class CommandLine implements Serializable {
      * @see PatternOptionBuilder
      * @since 1.10.0
      */
-    public <T> T[] getParsedOptionValues(final String opt, final T[] 
defaultValue) throws ParseException {
-        return getParsedOptionValues(resolveOption(opt), defaultValue);
+    public <T> T[] getParsedOptionValues(final String optionName, final T[] 
defaultValue) throws ParseException {
+        return getParsedOptionValues(resolveOption(optionName), defaultValue);
     }
 
     /**
@@ -918,24 +918,24 @@ public class CommandLine implements Serializable {
     /**
      * Tests to see if an option has been set.
      *
-     * @param opt character name of the option.
+     * @param optionChar character name of the option.
      * @return true if set, false if not.
      */
-    public boolean hasOption(final char opt) {
-        return hasOption(String.valueOf(opt));
+    public boolean hasOption(final char optionChar) {
+        return hasOption(String.valueOf(optionChar));
     }
 
     /**
      * Tests to see if an option has been set.
      *
-     * @param opt the option to check.
+     * @param option the option to check.
      * @return true if set, false if not.
      * @since 1.5.0
      */
-    public boolean hasOption(final Option opt) {
-        final boolean result = options.contains(opt);
-        if (result && opt.isDeprecated()) {
-            handleDeprecated(opt);
+    public boolean hasOption(final Option option) {
+        final boolean result = options.contains(option);
+        if (result && option.isDeprecated()) {
+            handleDeprecated(option);
         }
         return result;
     }
@@ -957,11 +957,11 @@ public class CommandLine implements Serializable {
     /**
      * Tests to see if an option has been set.
      *
-     * @param opt Short name of the option.
+     * @param optionName Short name of the option.
      * @return true if set, false if not.
      */
-    public boolean hasOption(final String opt) {
-        return hasOption(resolveOption(opt));
+    public boolean hasOption(final String optionName) {
+        return hasOption(resolveOption(optionName));
     }
 
     /**
@@ -993,11 +993,11 @@ public class CommandLine implements Serializable {
     /**
      * Retrieves the option object given the long or short option as a String
      *
-     * @param opt short or long name of the option, may be null.
+     * @param optionName short or long name of the option, may be null.
      * @return Canonicalized option.
      */
-    private Option resolveOption(final String opt) {
-        final String actual = Util.stripLeadingHyphens(opt);
+    private Option resolveOption(final String optionName) {
+        final String actual = Util.stripLeadingHyphens(optionName);
         if (actual != null) {
             for (final Option option : options) {
                 if (actual.equals(option.getOpt()) || 
actual.equals(option.getLongOpt())) {

Reply via email to