Package net.morimekta.console.args
Class Property
- java.lang.Object
-
- net.morimekta.console.args.BaseArgument
-
- net.morimekta.console.args.BaseOption
-
- net.morimekta.console.args.Property
-
public class Property extends BaseOption
A property is an option where the value is a key-value pair, and applies the key value onto a putter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Property.Putter
Basic interface for putting value onto a map, properties or config.
-
Constructor Summary
Constructors Constructor Description Property(char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties)
Create a property argument.Property(char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties, boolean hidden)
Create a property argument.Property(char shortName, java.lang.String usage, Property.Putter properties)
Create a property argument with default key and value names.Property(java.lang.String name, char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties, boolean hidden)
Create a property argument.Property(java.lang.String name, char shortName, java.lang.String usage, Property.Putter properties)
Create a property argument with default key and value names.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
apply(ArgumentList args)
Parse the argument list, including the argument string that triggered the call.int
applyShort(java.lang.String opts, ArgumentList args)
When handling a list of short options, except for the last short option.java.lang.String
getMetaKey()
java.lang.String
getPrefix()
Prefix part of the usage usage message.java.lang.String
getSingleLineUsage()
Get the argument's single line usage string.void
validate()
Called on all the arguments after the parsing is done to validate if all requirements have been passed.-
Methods inherited from class net.morimekta.console.args.BaseArgument
getDefaultValue, getName, getUsage, isHidden, isRepeated, isRequired
-
Methods inherited from class net.morimekta.console.args.BaseOption
getMetaVar, getShortNames, nameOrShort
-
-
-
-
Constructor Detail
-
Property
public Property(char shortName, java.lang.String usage, Property.Putter properties)
Create a property argument with default key and value names.- Parameters:
shortName
- The short name character.usage
- The usage string.properties
- The properties instance to populate.
-
Property
public Property(java.lang.String name, char shortName, java.lang.String usage, Property.Putter properties)
Create a property argument with default key and value names.- Parameters:
name
- The long option name.shortName
- The short name character.usage
- The usage string.properties
- The properties instance to populate.
-
Property
public Property(char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties)
Create a property argument.- Parameters:
shortName
- The short name character.metaKey
- The meta key name.metaVar
- The meta value name.usage
- The usage string.properties
- The properties instance to populate.
-
Property
public Property(char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties, boolean hidden)
Create a property argument.- Parameters:
shortName
- The short name character.metaKey
- The meta key name.metaVar
- The meta value name.usage
- The usage string.properties
- The properties instance to populate.hidden
- If the property argument should be hidden.
-
Property
public Property(java.lang.String name, char shortName, java.lang.String metaKey, java.lang.String metaVar, java.lang.String usage, Property.Putter properties, boolean hidden)
Create a property argument.- Parameters:
name
- The long option name.shortName
- The short name character.metaKey
- The meta key name.metaVar
- The meta value name.usage
- The usage string.properties
- The properties instance to populate.hidden
- If the property argument should be hidden.
-
-
Method Detail
-
getMetaKey
public java.lang.String getMetaKey()
- Returns:
- The meta key name.
-
getSingleLineUsage
public java.lang.String getSingleLineUsage()
Description copied from class:BaseArgument
Get the argument's single line usage string.- Overrides:
getSingleLineUsage
in classBaseOption
- Returns:
- The single-line usage string.
-
getPrefix
public java.lang.String getPrefix()
Description copied from class:BaseArgument
Prefix part of the usage usage message.- Overrides:
getPrefix
in classBaseOption
- Returns:
- The usage prefix.
-
validate
public void validate() throws ArgumentException
Description copied from class:BaseArgument
Called on all the arguments after the parsing is done to validate if all requirements have been passed. Should throw anArgumentException
if is did not validate with the appropriate error message.- Specified by:
validate
in classBaseArgument
- Throws:
ArgumentException
-
applyShort
public int applyShort(java.lang.String opts, ArgumentList args)
Description copied from class:BaseOption
When handling a list of short options, except for the last short option.- Specified by:
applyShort
in classBaseOption
- Parameters:
opts
- The remaining characters of the short opt list.args
- The list of arguments including the short opt list.- Returns:
- The number of arguments consumed. If 0 is returned, will handle as the short option char was the only thing being consumed.
-
apply
public int apply(ArgumentList args)
Description copied from class:BaseOption
Parse the argument list, including the argument string that triggered the call. And handle it's value or values.- Specified by:
apply
in classBaseOption
- Parameters:
args
- The list of arguments.- Returns:
- The number of arguments consumed.
-
-