Package fmpp.util
Class ArgsParser.OptionDefinition
java.lang.Object
fmpp.util.ArgsParser.OptionDefinition
- All Implemented Interfaces:
Cloneable
- Enclosing class:
ArgsParser
Describes and option. It does not store the actual value of the
option after parsing; it is just the definition of the option.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of the option with different short- and long-name, but with the same property name (and other attributes).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.Sets the description (used in help) of the option.Returns the name of the argument, or null if the option does not support argument.Returns the default argument of the option, or null if the option has no default argument.Returns the description of the option, or null if no description is available.Returns the long-name of the option, or null if the option has no long-name.Returns the short-name of the option, or null if the option has no short-name.Convenience method; same as callingproperty(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.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.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.Sets the property name for this option.Convenience method; same as callingproperty(String)
and thenpropertyValue
.propertyValue
(String value) Sets the property value for this option.
-
Constructor Details
-
OptionDefinition
public OptionDefinition()
-
-
Method Details
-
property
Sets the property name for this option. If you don't override the property name with this, it will be the long-name of the option if the option has long-name, otherwise the short-name of the option.- See Also:
-
propertyValue
Sets the property value for this option. This only allowed for options that do no support argument, as the value of options that has argument will be the actual value of the argument. If you don't override the property value with this, it will be "" (0 length String) for those options.- Throws:
IllegalArgumentException
- if the option has argument.- See Also:
-
property
Convenience method; same as callingproperty(String)
and thenpropertyValue
. This method only applies for options that do no support argument.- See Also:
-
group
Convenience method; same as callingproperty(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.- See Also:
-
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. Note that if the option supports argument, you have to useimplied(String)
.- Throws:
IllegalArgumentException
- if the option has argument.- See Also:
-
implied
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. This version of the method applies only for options that support argument.- Throws:
IllegalArgumentException
- if the option has no argument.- See Also:
-
defaultArg
Gives default argument value for an option that supports arguments, thus it will be optional to specify the argument value in the command-line.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
". -
desc
Sets the description (used in help) of the option. -
hide
public void hide()Hides option, that is, it will not be shown in the option help. -
copy
Creates a copy of the option with different short- and long-name, but with the same property name (and other attributes). This is mostly useful to create alias options.- Parameters:
shortName
- the short-name of option or null. Do not use the s=ARGNAME form here.longName
- the long-name of option or null. Do not use the long-name=ARGNAME form here.- Returns:
- the newly created
OptionDefinition
. - Throws:
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.
-
getArgName
Returns the name of the argument, or null if the option does not support argument. -
getDefaultArg
Returns the default argument of the option, or null if the option has no default argument. -
getDescription
Returns the description of the option, or null if no description is available. -
getLongName
Returns the long-name of the option, or null if the option has no long-name. -
getShortName
Returns the short-name of the option, or null if the option has no short-name.
-