|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.cli.HelpFormatter
public class HelpFormatter
A formatter of help messages for the current command line options
Field Summary | |
---|---|
static String |
DEFAULT_ARG_NAME
default name for an argument |
static int |
DEFAULT_DESC_PAD
the number of characters of padding to be prefixed to each description line |
static int |
DEFAULT_LEFT_PAD
default padding to the left of each line |
static String |
DEFAULT_LONG_OPT_PREFIX
default prefix for long Option |
static String |
DEFAULT_OPT_PREFIX
default prefix for shortOpts |
static String |
DEFAULT_SYNTAX_PREFIX
the string to display at the beginning of the usage statement |
static int |
DEFAULT_WIDTH
default number of characters per line |
String |
defaultArgName
Deprecated. Scope will be made private for next major version - use get/setArgName methods instead. |
int |
defaultDescPad
Deprecated. Scope will be made private for next major version - use get/setDescPadding methods instead. |
int |
defaultLeftPad
Deprecated. Scope will be made private for next major version - use get/setLeftPadding methods instead. |
String |
defaultLongOptPrefix
Deprecated. Scope will be made private for next major version - use get/setLongOptPrefix methods instead. |
String |
defaultNewLine
Deprecated. Scope will be made private for next major version - use get/setNewLine methods instead. |
String |
defaultOptPrefix
Deprecated. Scope will be made private for next major version - use get/setOptPrefix methods instead. |
String |
defaultSyntaxPrefix
Deprecated. Scope will be made private for next major version - use get/setSyntaxPrefix methods instead. |
int |
defaultWidth
Deprecated. Scope will be made private for next major version - use get/setWidth methods instead. |
protected Comparator |
optionComparator
Comparator used to sort the options when they output in help text Defaults to case-insensitive alphabetical sorting by option key |
Constructor Summary | |
---|---|
HelpFormatter()
|
Method Summary | |
---|---|
protected String |
createPadding(int len)
Return a String of padding of length len . |
protected int |
findWrapPos(String text,
int width,
int startPos)
Finds the next text wrap position after startPos for the
text in text with the column width width . |
String |
getArgName()
Returns the 'argName'. |
int |
getDescPadding()
Returns the 'descPadding'. |
int |
getLeftPadding()
Returns the 'leftPadding'. |
String |
getLongOptPrefix()
Returns the 'longOptPrefix'. |
String |
getNewLine()
Returns the 'newLine'. |
Comparator |
getOptionComparator()
Comparator used to sort the options when they output in help text Defaults to case-insensitive alphabetical sorting by option key |
String |
getOptPrefix()
Returns the 'optPrefix'. |
String |
getSyntaxPrefix()
Returns the 'syntaxPrefix'. |
int |
getWidth()
Returns the 'width'. |
void |
printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer)
Print the help for options with the specified
command line syntax. |
void |
printHelp(int width,
String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
Print the help for options with the specified
command line syntax. |
void |
printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer)
Print the help for options with the specified
command line syntax. |
void |
printHelp(PrintWriter pw,
int width,
String cmdLineSyntax,
String header,
Options options,
int leftPad,
int descPad,
String footer,
boolean autoUsage)
Print the help for options with the specified
command line syntax. |
void |
printHelp(String cmdLineSyntax,
Options options)
Print the help for options with the specified
command line syntax. |
void |
printHelp(String cmdLineSyntax,
Options options,
boolean autoUsage)
Print the help for options with the specified
command line syntax. |
void |
printHelp(String cmdLineSyntax,
String header,
Options options,
String footer)
Print the help for options with the specified
command line syntax. |
void |
printHelp(String cmdLineSyntax,
String header,
Options options,
String footer,
boolean autoUsage)
Print the help for options with the specified
command line syntax. |
void |
printOptions(PrintWriter pw,
int width,
Options options,
int leftPad,
int descPad)
Print the help for the specified Options to the specified writer, using the specified width, left padding and description padding. |
void |
printUsage(PrintWriter pw,
int width,
String cmdLineSyntax)
Print the cmdLineSyntax to the specified writer, using the specified width. |
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)
Print the specified text to the specified PrintWriter. |
void |
printWrapped(PrintWriter pw,
int width,
String text)
Print the specified text to the specified PrintWriter. |
protected StringBuffer |
renderOptions(StringBuffer sb,
int width,
Options options,
int leftPad,
int descPad)
Render the specified Options and return the rendered Options in a StringBuffer. |
protected StringBuffer |
renderWrappedText(StringBuffer sb,
int width,
int nextLineTabStop,
String text)
Render the specified text and return the rendered Options in a StringBuffer. |
protected String |
rtrim(String s)
Remove the trailing whitespace from the specified String. |
void |
setArgName(String name)
Sets the 'argName'. |
void |
setDescPadding(int padding)
Sets the 'descPadding'. |
void |
setLeftPadding(int padding)
Sets the 'leftPadding'. |
void |
setLongOptPrefix(String prefix)
Sets the 'longOptPrefix'. |
void |
setNewLine(String newline)
Sets the 'newLine'. |
void |
setOptionComparator(Comparator comparator)
Set the comparator used to sort the options when they output in help text Passing in a null parameter will set the ordering to the default mode |
void |
setOptPrefix(String prefix)
Sets the 'optPrefix'. |
void |
setSyntaxPrefix(String prefix)
Sets the 'syntaxPrefix'. |
void |
setWidth(int width)
Sets the 'width'. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_WIDTH
public static final int DEFAULT_LEFT_PAD
public static final int DEFAULT_DESC_PAD
public static final String DEFAULT_SYNTAX_PREFIX
public static final String DEFAULT_OPT_PREFIX
public static final String DEFAULT_LONG_OPT_PREFIX
public static final String DEFAULT_ARG_NAME
public int defaultWidth
public int defaultLeftPad
public int defaultDescPad
public String defaultSyntaxPrefix
public String defaultNewLine
public String defaultOptPrefix
public String defaultLongOptPrefix
public String defaultArgName
protected Comparator optionComparator
Constructor Detail |
---|
public HelpFormatter()
Method Detail |
---|
public void setWidth(int width)
width
- the new value of 'width'public int getWidth()
public void setLeftPadding(int padding)
padding
- the new value of 'leftPadding'public int getLeftPadding()
public void setDescPadding(int padding)
padding
- the new value of 'descPadding'public int getDescPadding()
public void setSyntaxPrefix(String prefix)
prefix
- the new value of 'syntaxPrefix'public String getSyntaxPrefix()
public void setNewLine(String newline)
newline
- the new value of 'newLine'public String getNewLine()
public void setOptPrefix(String prefix)
prefix
- the new value of 'optPrefix'public String getOptPrefix()
public void setLongOptPrefix(String prefix)
prefix
- the new value of 'longOptPrefix'public String getLongOptPrefix()
public void setArgName(String name)
name
- the new value of 'argName'public String getArgName()
public Comparator getOptionComparator()
public void setOptionComparator(Comparator comparator)
public void printHelp(String cmdLineSyntax, Options options)
options
with the specified
command line syntax. This method prints help information to
System.out.
cmdLineSyntax
- the syntax for this applicationoptions
- the Options instancepublic void printHelp(String cmdLineSyntax, Options options, boolean autoUsage)
options
with the specified
command line syntax. This method prints help information to
System.out.
cmdLineSyntax
- the syntax for this applicationoptions
- the Options instanceautoUsage
- whether to print an automatically generated
usage statementpublic void printHelp(String cmdLineSyntax, String header, Options options, String footer)
options
with the specified
command line syntax. This method prints help information to
System.out.
cmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helppublic void printHelp(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
options
with the specified
command line syntax. This method prints help information to
System.out.
cmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated
usage statementpublic void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer)
options
with the specified
command line syntax. This method prints help information to
System.out.
width
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the beginning of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helppublic void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
options
with the specified
command line syntax. This method prints help information to
System.out.
width
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated
usage statementpublic void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer)
options
with the specified
command line syntax.
pw
- the writer to which the help will be writtenwidth
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instanceleftPad
- the number of characters of padding to be prefixed
to each linedescPad
- the number of characters of padding to be prefixed
to each description linefooter
- the banner to display at the end of the help
IllegalStateException
- if there is no room to print a linepublic void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer, boolean autoUsage)
options
with the specified
command line syntax.
pw
- the writer to which the help will be writtenwidth
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instanceleftPad
- the number of characters of padding to be prefixed
to each linedescPad
- the number of characters of padding to be prefixed
to each description linefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated
usage statement
IllegalStateException
- if there is no room to print a linepublic void printUsage(PrintWriter pw, int width, String app, Options options)
Prints the usage statement for the specified application.
pw
- The PrintWriter to print the usage statementwidth
- The number of characters to display per lineapp
- The application nameoptions
- The command line Optionspublic void printUsage(PrintWriter pw, int width, String cmdLineSyntax)
pw
- The printWriter to write the help towidth
- The number of characters per line for the usage statement.cmdLineSyntax
- The usage statement.public void printOptions(PrintWriter pw, int width, Options options, int leftPad, int descPad)
Print the help for the specified Options to the specified writer, using the specified width, left padding and description padding.
pw
- The printWriter to write the help towidth
- The number of characters to display per lineoptions
- The command line OptionsleftPad
- the number of characters of padding to be prefixed
to each linedescPad
- the number of characters of padding to be prefixed
to each description linepublic void printWrapped(PrintWriter pw, int width, String text)
pw
- The printWriter to write the help towidth
- The number of characters to display per linetext
- The text to be written to the PrintWriterpublic void printWrapped(PrintWriter pw, int width, int nextLineTabStop, String text)
pw
- The printWriter to write the help towidth
- The number of characters to display per linenextLineTabStop
- The position on the next line for the first tab.text
- The text to be written to the PrintWriterprotected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
sb
- The StringBuffer to place the rendered Options into.width
- The number of characters to display per lineoptions
- The command line OptionsleftPad
- the number of characters of padding to be prefixed
to each linedescPad
- the number of characters of padding to be prefixed
to each description line
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text)
sb
- The StringBuffer to place the rendered text into.width
- The number of characters to display per linenextLineTabStop
- The position on the next line for the first tab.text
- The text to be rendered.
protected int findWrapPos(String text, int width, int startPos)
startPos
for the
text in text
with the column width width
.
The wrap point is the last postion before startPos+width having a
whitespace character (space, \n, \r).
text
- The text being searched for the wrap positionwidth
- width of the wrapped textstartPos
- position from which to start the lookup whitespace
character
protected String createPadding(int len)
len
.
len
- The length of the String of padding to create.
protected String rtrim(String s)
s
- The String to remove the trailing padding from.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |