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 2025/12/31 15:35:56 UTC
(commons-cli) branch master updated: [CLI-352] Correct HelpFormatter Javadoc (#418)
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 c4dddc7f [CLI-352] Correct HelpFormatter Javadoc (#418)
c4dddc7f is described below
commit c4dddc7f694770a610ad9486ef28fb8a57e792c2
Author: Ken Dombeck <kd...@users.noreply.github.com>
AuthorDate: Wed Dec 31 09:35:51 2025 -0600
[CLI-352] Correct HelpFormatter Javadoc (#418)
* [CLI-352] Correct HelpFormatter Javadoc
* [CLI-352] Correct HelpFormatter Javadoc
* Use overloaded builder method
to define option rather than specifiying it separately. This will be more consistent with other documented uses.
---------
Co-authored-by: Ken Dombeck <ke...@target.com>
---
src/main/java/org/apache/commons/cli/HelpFormatter.java | 6 +++---
src/main/java/org/apache/commons/cli/help/HelpFormatter.java | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/cli/HelpFormatter.java b/src/main/java/org/apache/commons/cli/HelpFormatter.java
index fb9da62e..febdf4c8 100644
--- a/src/main/java/org/apache/commons/cli/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/HelpFormatter.java
@@ -44,9 +44,9 @@ import org.apache.commons.cli.help.OptionFormatter;
* </p>
* <pre>
* Options options = new Options();
- * options.addOption(OptionBuilder.withLongOpt("file").withDescription("The file to be processed").hasArg().withArgName("FILE").isRequired().create('f'));
- * options.addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version of the application").create('v'));
- * options.addOption(OptionBuilder.withLongOpt("help").create('h'));
+ * options.addOption(Option.builder("f").longOpt("file").desc("The file to be processed").hasArg().argName("FILE").required().get());
+ * options.addOption(Option.builder("v").longOpt("version").desc("Print the version of the application").get());
+ * options.addOption(Option.builder("h").longOpt("help").get());
*
* String header = "Do something useful with an input file\n\n";
* String footer = "\nPlease report issues at https://example.com/issues";
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 c4081ec4..f0723706 100644
--- a/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
+++ b/src/main/java/org/apache/commons/cli/help/HelpFormatter.java
@@ -31,14 +31,14 @@ import org.apache.commons.cli.Option;
*
* <pre>
* Options options = new Options();
- * options.addOption(OptionBuilder.withLongOpt("file").withDescription("The file to be processed").hasArg().withArgName("FILE").isRequired().create('f'));
- * options.addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version of the application").create('v'));
- * options.addOption(OptionBuilder.withLongOpt("help").create('h'));
+ * options.addOption(Option.builder("f").longOpt("file").desc("The file to be processed").hasArg().argName("FILE").required().get());
+ * options.addOption(Option.builder("v").longOpt("version").desc("Print the version of the application").get());
+ * options.addOption(Option.builder("h").longOpt("help").get());
*
* String header = "Do something useful with an input file";
* String footer = "Please report issues at https://example.com/issues";
*
- * HelpFormatter formatter = new HelpFormatter();
+ * HelpFormatter formatter = HelpFormatter.builder().get();
* formatter.printHelp("myapp", header, options, footer, true);
* </pre>
* <p>