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 b906eee28a99c02c8c1b90f156f16e228bab186a Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun May 19 10:32:43 2024 -0400 Sort members --- .../java/org/apache/commons/cli/HelpFormatter.java | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/cli/HelpFormatter.java b/src/main/java/org/apache/commons/cli/HelpFormatter.java index 1884437..3d6c280 100644 --- a/src/main/java/org/apache/commons/cli/HelpFormatter.java +++ b/src/main/java/org/apache/commons/cli/HelpFormatter.java @@ -109,36 +109,26 @@ public class HelpFormatter { /** * Sets whether to show deprecated options. * - * @param showDeprecatedFunc Specify the format for the deprecated options. + * @param useDefaultFormat if {@code true} use the default format, otherwise clear the formatter. * @return this. - * @since 1.8.0 */ - public Builder setShowDeprecated(final Function<Option, String> showDeprecatedFunc) { - this.deprecatedFormatFunc = showDeprecatedFunc; - return this; + public Builder setShowDeprecated(final boolean useDefaultFormat) { + return setShowDeprecated(useDefaultFormat ? DEFAULT_DEPRECATED_FORMAT : null); } /** * Sets whether to show deprecated options. * - * @param useDefaultFormat if {@code true} use the default format, otherwise clear the formatter. + * @param showDeprecatedFunc Specify the format for the deprecated options. * @return this. + * @since 1.8.0 */ - public Builder setShowDeprecated(final boolean useDefaultFormat) { - return setShowDeprecated(useDefaultFormat ? DEFAULT_DEPRECATED_FORMAT : null); + public Builder setShowDeprecated(final Function<Option, String> showDeprecatedFunc) { + this.deprecatedFormatFunc = showDeprecatedFunc; + return this; } } - /** - * Gets the option description or an empty string if the description is {@code null}. - * @param option The option to get the description from. - * @return the option description or an empty string if the description is {@code null}. - * @since 1.8.0 - */ - public static String getDescription(final Option option) { - String desc = option.getDescription(); - return desc == null ? "" : desc; - } /** * This class implements the {@code Comparator} interface for comparing Options. */ @@ -161,7 +151,6 @@ public class HelpFormatter { return opt1.getKey().compareToIgnoreCase(opt2.getKey()); } } - /** Default number of characters per line */ public static final int DEFAULT_WIDTH = 74; @@ -204,6 +193,17 @@ public class HelpFormatter { return new PrintWriter(System.out); } + /** + * Gets the option description or an empty string if the description is {@code null}. + * @param option The option to get the description from. + * @return the option description or an empty string if the description is {@code null}. + * @since 1.8.0 + */ + public static String getDescription(final Option option) { + String desc = option.getDescription(); + return desc == null ? "" : desc; + } + /** * Number of characters per line *