Skip to content

Commit 4f1b238

Browse files
committed
Improved the javadoc of HelpFormatter
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@1403711 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1041870 commit 4f1b238

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

src/main/java/org/apache/commons/cli/HelpFormatter.java

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,43 @@
3030
import java.util.List;
3131

3232
/**
33-
* A formatter of help messages for the current command line options
33+
* A formatter of help messages for command line options.
3434
*
35+
* <p>Example:</p>
36+
*
37+
* <pre>
38+
* Options options = new Options();
39+
* options.addOption(OptionBuilder.withLongOpt("file")
40+
* .withDescription("The file to be processed")
41+
* .hasArg()
42+
* .withArgName("FILE")
43+
* .isRequired()
44+
* .create('f'));
45+
* options.addOption(OptionBuilder.withLongOpt("version")
46+
* .withDescription("Print the version of the application")
47+
* .create('v'));
48+
* options.addOption(OptionBuilder.withLongOpt("help").create('h'));
49+
*
50+
* String header = "Do something useful with an input file\n\n";
51+
* String footer = "\nPlease report issues at http://example.com/issues";
52+
*
53+
* HelpFormatter formatter = new HelpFormatter();
54+
* formatter.printHelp("myapp", header, options, footer, true);
55+
* </pre>
56+
*
57+
* This produces the following output:
58+
*
59+
* <pre>
60+
* usage: myapp -f <FILE> [-h] [-v]
61+
* Do something useful with an input file
62+
*
63+
* -f,--file &lt;FILE> The file to be processed
64+
* -h,--help
65+
* -v,--version Print the version of the application
66+
*
67+
* Please report issues at http://example.com/issues
68+
* </pre>
69+
*
3570
* @author Slawek Zachcial
3671
* @author John Keyes (john at integralsource.com)
3772
* @version $Revision$, $Date$
@@ -46,10 +81,7 @@ public class HelpFormatter
4681
/** default padding to the left of each line */
4782
public static final int DEFAULT_LEFT_PAD = 1;
4883

49-
/**
50-
* the number of characters of padding to be prefixed
51-
* to each description line
52-
*/
84+
/** number of space characters to be prefixed to each description line */
5385
public static final int DEFAULT_DESC_PAD = 3;
5486

5587
/** the string to display at the beginning of the usage statement */

0 commit comments

Comments
 (0)