public final class UsageInfo
extends java.lang.Object
CommandLineUtility.getCustomUsageInfo(UsageInfo)
for more information how to use this class.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LONG_OPTION_PREFIX |
static char |
NO_SHORT_OPTION
Constant to use for a short option, to indicate that there is no
short option.
|
static char |
SHORT_OPTION_PREFIX
The option prefix strings used at the command line.
|
Constructor and Description |
---|
UsageInfo()
Create a new UsageInfo() object.
|
Modifier and Type | Method and Description |
---|---|
void |
addOption(char shortOption,
java.lang.String longOption,
java.lang.String explanation)
Add an option and its explanation to the usage information.
|
void |
addOption(char shortOption,
java.lang.String longOption,
java.lang.String argToken,
java.lang.String explanation)
Add an option and its explanation to the usage information.
|
void |
addParameter(java.lang.String param,
java.lang.String explanation,
boolean required)
Add a positional parameter (i.e., one that follows the options) and
its explanation to the usage information at the end of the list of
positional parameters.
|
void |
addUsagePrologue(java.lang.String prologue)
Add a prologue to be displayed before the standard usage message.
|
void |
addUsageTrailer(java.lang.String trailer)
Add a trailer to be displayed after the standard usage message.
|
java.lang.String |
getCommandName()
Get the command name to be used in the usage output.
|
void |
setCommandName(java.lang.String commandName)
Set the command name to be used in the usage output.
|
public static final char NO_SHORT_OPTION
public static final char SHORT_OPTION_PREFIX
public static final java.lang.String LONG_OPTION_PREFIX
public java.lang.String getCommandName()
setCommandName(java.lang.String)
public void setCommandName(java.lang.String commandName)
commandName
- the command namegetCommandName()
public void addOption(char shortOption, java.lang.String longOption, java.lang.String explanation)
That is, it's useful for options that take no parameters.addOption(
(shortOption, longOption, null, explanation)
shortOption
- The single-character short option (e.g., 'a'
for "-a"), or NO_SHORT_OPTION
to indicate
that there is no short option.longOption
- The corresponding long option, if any, or null.
The option should be specified without any leading
"-" character (e.g., "logging", not "--logging").explanation
- A one-line explanation for the option. The line
can be as long as you want, and can contain multiple
sentences, but it must not contain a newline.
It will be automatically broken up into multiple
lines as necessary. If the explanation is null,
then the option is "hidden" (i.e., not displayed
in the usage message). This is useful, for instance,
when you've deprecated an option but are retaining
it for backward compatibility.public void addOption(char shortOption, java.lang.String longOption, java.lang.String argToken, java.lang.String explanation)
usageInfo.addOption ('n', "total-images", "num", "Total number of images to generate"); usageInfo.addOption ('v', "verbose", null, "Enable verbose mode")
shortOption
- The single-character short option (e.g., 'a'
for "-a"), or NO_SHORT_OPTION
to indicate
that there is no short option.longOption
- The corresponding long option, if any, or null.
The option should be specified without any leading
"-" character (e.g., "logging", not "--logging").argToken
- A token to represent the option's parameter, if any,
in the generated usage message. null if the option
takes no parameters.explanation
- A one-line explanation for the option. The line
can be as long as you want, and can contain multiple
sentences, but it must not contain a newline.
It will be automatically broken up into multiple
lines as necessary. If the explanation is null,
then the option is "hidden" (i.e., not displayed
in the usage message). This is useful, for instance,
when you've deprecated an option but are retaining
it for backward compatibility.public void addParameter(java.lang.String param, java.lang.String explanation, boolean required)
param
- The parameter placeholder stringexplanation
- A one-line explanation for the parameter. The line
can be as long as you want, and can contain multiple
sentences, but it must not contain a newline.
It will be automatically broken up into multiple
lines as necessary.required
- true if the parameter is required,
false if the parameter is optionalpublic void addUsagePrologue(java.lang.String prologue)
prologue
- the prologue stringaddUsageTrailer(java.lang.String)
public void addUsageTrailer(java.lang.String trailer)
trailer
- the trailer stringaddUsageTrailer(java.lang.String)