public class ArgsParser.OptionDefinition extends Object implements Cloneable
Constructor and Description |
---|
OptionDefinition() |
Modifier and Type | Method and Description |
---|---|
ArgsParser.OptionDefinition |
copy(String shortName,
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(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(String desc)
Sets the description (used in help) of the option.
|
String |
getArgName()
Returns the name of the argument, or null if the option does not
support argument.
|
String |
getDefaultArg()
Returns the default argument of the option, or null if the option
has no default argument.
|
String |
getDescription()
Returns the description of the option, or null if no description is
available.
|
String |
getLongName()
Returns the long-name of the option, or null if the option has no
long-name.
|
String |
getShortName()
Returns the short-name of the option, or null if the option has no
short-name.
|
ArgsParser.OptionDefinition |
group(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(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(String pName)
Sets the property name for this option.
|
ArgsParser.OptionDefinition |
property(String propertyName,
String propertyValue)
Convenience method; same as calling
property(String) and
then propertyValue . |
ArgsParser.OptionDefinition |
propertyValue(String value)
Sets the property value for this option.
|
public ArgsParser.OptionDefinition property(String pName)
property(String, String)
public ArgsParser.OptionDefinition propertyValue(String value)
IllegalArgumentException
- if the option has argument.property(String, String)
public ArgsParser.OptionDefinition property(String propertyName, 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(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)
.IllegalArgumentException
- if the option has argument.implied(String)
public ArgsParser.OptionDefinition implied(String impliedArg)
IllegalArgumentException
- if the option has no argument.implied()
public ArgsParser.OptionDefinition defaultArg(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(String desc)
public void hide()
public ArgsParser.OptionDefinition copy(String shortName, 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
.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 String getArgName()
public String getDefaultArg()
public String getDescription()
public String getLongName()
public String getShortName()