org.apache.commons.cli
Class HelpFormatter
java.lang.Object
org.apache.commons.cli.HelpFormatter
- public class HelpFormatter
- extends Object
A formatter of help messages for the current command line options
- Author:
- Slawek Zachcial, John Keyes (john at integralsource.com)
Method Summary |
protected String |
createPadding(int len)
|
protected int |
findWrapPos(String text,
int width,
int startPos)
Finds the next text wrap position after startPos for the text
in sb with the column width width . |
void |
printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer)
|
void |
printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
|
void |
printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer)
|
void |
printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer,
boolean autoUsage)
|
void |
printHelp(String cmdLineSyntax,
Options options)
|
void |
printHelp(String cmdLineSyntax,
Options options,
boolean autoUsage)
|
void |
printHelp(String cmdLineSyntax,
String header,
Options options,
String footer)
|
void |
printHelp(String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
|
void |
printOptions(PrintWriter pw,
int width,
Options options,
int leftPad,
int descPad)
|
void |
printUsage(PrintWriter pw,
int width,
String cmdLineSyntax)
|
void |
printUsage(PrintWriter pw,
int width,
String app,
Options options)
Prints the usage statement for the specified application. |
void |
printWrapped(PrintWriter pw,
int width,
int nextLineTabStop,
String text)
|
void |
printWrapped(PrintWriter pw,
int width,
String text)
|
protected StringBuffer |
renderOptions(StringBuffer sb,
int width,
Options options,
int leftPad,
int descPad)
|
protected StringBuffer |
renderWrappedText(StringBuffer sb,
int width,
int nextLineTabStop,
String text)
|
protected String |
rtrim(String s)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_WIDTH
public static final int DEFAULT_WIDTH
- See Also:
- Constant Field Values
DEFAULT_LEFT_PAD
public static final int DEFAULT_LEFT_PAD
- See Also:
- Constant Field Values
DEFAULT_DESC_PAD
public static final int DEFAULT_DESC_PAD
- See Also:
- Constant Field Values
DEFAULT_SYNTAX_PREFIX
public static final String DEFAULT_SYNTAX_PREFIX
- See Also:
- Constant Field Values
DEFAULT_OPT_PREFIX
public static final String DEFAULT_OPT_PREFIX
- See Also:
- Constant Field Values
DEFAULT_LONG_OPT_PREFIX
public static final String DEFAULT_LONG_OPT_PREFIX
- See Also:
- Constant Field Values
DEFAULT_ARG_NAME
public static final String DEFAULT_ARG_NAME
- See Also:
- Constant Field Values
defaultWidth
public int defaultWidth
defaultLeftPad
public int defaultLeftPad
defaultDescPad
public int defaultDescPad
defaultSyntaxPrefix
public String defaultSyntaxPrefix
defaultNewLine
public String defaultNewLine
defaultOptPrefix
public String defaultOptPrefix
defaultLongOptPrefix
public String defaultLongOptPrefix
defaultArgName
public String defaultArgName
HelpFormatter
public HelpFormatter()
printHelp
public void printHelp(String cmdLineSyntax,
Options options)
printHelp
public void printHelp(String cmdLineSyntax,
Options options,
boolean autoUsage)
printHelp
public void printHelp(String cmdLineSyntax,
String header,
Options options,
String footer)
printHelp
public void printHelp(String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
printHelp
public void printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer)
printHelp
public void printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
printHelp
public void printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
printHelp
public void printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer,
boolean autoUsage)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
printUsage
public void printUsage(PrintWriter pw,
int width,
String app,
Options options)
Prints the usage statement for the specified application.
- Parameters:
pw
- The PrintWriter to print the usage statementwidth
- ??options
- The command line Options
printUsage
public void printUsage(PrintWriter pw,
int width,
String cmdLineSyntax)
printOptions
public void printOptions(PrintWriter pw,
int width,
Options options,
int leftPad,
int descPad)
printWrapped
public void printWrapped(PrintWriter pw,
int width,
String text)
printWrapped
public void printWrapped(PrintWriter pw,
int width,
int nextLineTabStop,
String text)
renderOptions
protected StringBuffer renderOptions(StringBuffer sb,
int width,
Options options,
int leftPad,
int descPad)
renderWrappedText
protected StringBuffer renderWrappedText(StringBuffer sb,
int width,
int nextLineTabStop,
String text)
findWrapPos
protected int findWrapPos(String text,
int width,
int startPos)
- Finds the next text wrap position after
startPos
for the text
in sb
with the column width width
.
The wrap point is the last postion before startPos+width having a whitespace
character (space, \n, \r).
- Parameters:
width
- width of the wrapped textstartPos
- position from which to start the lookup whitespace character
- Returns:
- postion on which the text must be wrapped or -1 if the wrap position is at the end
of the text
createPadding
protected String createPadding(int len)
rtrim
protected String rtrim(String s)