public class ArgsParser.OptionDefinition
extends java.lang.Object
implements java.lang.Cloneable
| Constructor and Description |
|---|
OptionDefinition() |
| Modifier and Type | Method and Description |
|---|---|
ArgsParser.OptionDefinition |
copy(java.lang.String shortName,
java.lang.String longName)
Creates a copy of the option with different short- and long-name,
but with the same property name (and other attributes).
|
ArgsParser.OptionDefinition |
defaultArg(java.lang.String defaultValue)
Gives default argument value for an option that supports arguments,
thus it will be optional to specify the argument value in the
command-line.
|
ArgsParser.OptionDefinition |
desc(java.lang.String desc)
Sets the description (used in help) of the option.
|
java.lang.String |
getArgName()
Returns the name of the argument, or null if the option does not
support argument.
|
java.lang.String |
getDefaultArg()
Returns the default argument of the option, or null if the option
has no default argument.
|
java.lang.String |
getDescription()
Returns the description of the option, or null if no description is
available.
|
java.lang.String |
getLongName()
Returns the long-name of the option, or null if the option has no
long-name.
|
java.lang.String |
getShortName()
Returns the short-name of the option, or null if the option has no
short-name.
|
ArgsParser.OptionDefinition |
group(java.lang.String propertyName)
Convenience method; same as calling
property(propertyName, optionName), where optionName
is the long-name if that exists, otherwise the short-name. |
void |
hide()
Hides option, that is, it will not be shown in the option help.
|
ArgsParser.OptionDefinition |
implied()
Ensures that the option will be seemingly present if the
args[] does not contains this option or any other option that
mutually excludes this option.
|
ArgsParser.OptionDefinition |
implied(java.lang.String impliedArg)
Ensures that the option will be seemingly present with the given
argument value if args[] does not contains this option, or any
other option that mutually excludes this option.
|
ArgsParser.OptionDefinition |
property(java.lang.String pName)
Sets the property name for this option.
|
ArgsParser.OptionDefinition |
property(java.lang.String propertyName,
java.lang.String propertyValue)
Convenience method; same as calling
property(String) and
then propertyValue. |
ArgsParser.OptionDefinition |
propertyValue(java.lang.String value)
Sets the property value for this option.
|
public ArgsParser.OptionDefinition property(java.lang.String pName)
property(String, String)public ArgsParser.OptionDefinition propertyValue(java.lang.String value)
java.lang.IllegalArgumentException - if the option has argument.property(String, String)public ArgsParser.OptionDefinition property(java.lang.String propertyName, java.lang.String propertyValue)
property(String) and
then propertyValue. This method only applies for
options that do no support argument.property(String),
propertyValue(java.lang.String)public ArgsParser.OptionDefinition group(java.lang.String propertyName)
property(propertyName, optionName), where optionName
is the long-name if that exists, otherwise the short-name.
This method only applies for options that do no support argument.property(String),
propertyValue(java.lang.String)public ArgsParser.OptionDefinition implied()
implied(String).java.lang.IllegalArgumentException - if the option has argument.implied(String)public ArgsParser.OptionDefinition implied(java.lang.String impliedArg)
java.lang.IllegalArgumentException - if the option has no argument.implied()public ArgsParser.OptionDefinition defaultArg(java.lang.String defaultValue)
Note that introducing default value for an option is not a
backward compatible step. For example if "color" has no default
value, then "--color red" is interpreted as "color"
has an argument that is "red". But, if "color" has a default value,
then it is interpreted as "color" has the default value, and
we have a non-option "red". Of coruse, there would not be problem
if we use "--color=red".
public ArgsParser.OptionDefinition desc(java.lang.String desc)
public void hide()
public ArgsParser.OptionDefinition copy(java.lang.String shortName, java.lang.String longName)
longName - the long-name of option or null.
Do not use the long-name=ARGNAME form here.shortName - the short-name of option or null.
Do not use the s=ARGNAME form here.OptionDefinition.java.lang.IllegalArgumentException - If an option with the same
long-name or short-name is already added, or if the given long-
or short-name is malformed.public java.lang.String getArgName()
public java.lang.String getDefaultArg()
public java.lang.String getDescription()
public java.lang.String getLongName()
public java.lang.String getShortName()