@Target(value=TYPE) @Retention(value=RUNTIME) @Documented public @interface Parser
When applied to a class that is also annotated with the Command
annotation then if that class is used with
SingleCommand.singleCommand(Class)
the parser configuration will
automatically be detected from this annotation.
When specifying a CLI via the Cli
annotation then this annotation may
be included as an argument to the Cli.parserConfiguration()
field to
provide a parser configuration for the CLI.
Modifier and Type | Optional Element and Description |
---|---|
Alias[] |
aliases
Defines command aliases
|
boolean |
aliasesMayChain
Controls whether command alises may be chained i.e.
|
boolean |
aliasesOverrideBuiltIns
Controls whether aliases are allowed to override built-in commands i.e.
|
boolean |
allowCommandAbbreviation
Controls whether command names may be abbreviated provided such
abbreviations are unambiguous (default false)
|
boolean |
allowOptionAbbreviation
Controls whether options names may be abbreviated provided such
abbreviations are unambiguous (default false)
|
String |
argumentsSeparator
Controls the separator that is used to distinguish options from arguments
were arguments may be confused as options
|
Class<? extends CommandFactory> |
commandFactory
Sets the command factory class to use
|
boolean |
defaultParsersFirst
Sets whether to use the default option parsers first before any
additional option parsers that may be defined (default true)
|
Class<? extends ParserErrorHandler> |
errorHandler
Sets the error handler to use, defaults to
FailFast which throws
errors as soon as they are encountered |
String |
flagNegationPrefix
Sets the flag negation prefix
|
Class<? extends NumericTypeConverter> |
numericTypeConverter
Sets the numeric type converter to use, this is used in conjunction with
the value of the
typeConverter() , if that class does not respect
NumericTypeConverter instances then this field has no effect |
Class<? extends OptionParser>[] |
optionParsers
Sets the option parser classes to be used
|
Class<? extends TypeConverter> |
typeConverter
Sets the type converter class to use
|
boolean |
useDefaultOptionParsers
Sets whether to use the default set of option parsers (default true)
|
String |
userAliasesFile
Defines the name of a file from which user defined command aliases should
be read
|
String |
userAliasesPrefix
Sets the prefix used for properties that define aliases
|
String[] |
userAliasesSearchLocation
Defines the search locations (i.e.
|
public abstract boolean allowCommandAbbreviation
public abstract boolean allowOptionAbbreviation
public abstract String argumentsSeparator
The default is --
which is the widely used convention
public abstract boolean aliasesMayChain
Note that even when enabled circular references are not permitted
public abstract boolean aliasesOverrideBuiltIns
This is particularly important if you allow users to define aliases since allowing overriding would allow them to change the behaviour from the default expected
public abstract Alias[] aliases
public abstract String userAliasesFile
public abstract String[] userAliasesSearchLocation
These should be given in order of preference, properties from all locations will be merged together such that properties from the locations earlier in this list take precedence
Search locations may start with ~/
or ~\
(depending on
the target platform) to refer to the home directory
public abstract String userAliasesPrefix
This is useful if you use the same properties file to store general
properties for your application in the same properties file. If set only
properties whose names begin with these prefix are treated as alias
definition with the prefix being stripped. So for example if you have a
prefix of foo.
and defined a property foo.bar
then you
would be defining an alias bar
public abstract boolean useDefaultOptionParsers
public abstract boolean defaultParsersFirst
public abstract Class<? extends OptionParser>[] optionParsers
public abstract Class<? extends CommandFactory> commandFactory
public abstract Class<? extends TypeConverter> typeConverter
public abstract Class<? extends NumericTypeConverter> numericTypeConverter
typeConverter()
, if that class does not respect
NumericTypeConverter
instances then this field has no effectpublic abstract Class<? extends ParserErrorHandler> errorHandler
FailFast
which throws
errors as soon as they are encounteredpublic abstract String flagNegationPrefix
If set flag options (those with arity zero) will have their value set to
false
if the name used starts with this prefix. For example if
the prefix is set to --no-
and the user specifies a flag that
begins with this the option will be set to false
. Note that an
appropriate name must be present in the Option.name()
for the
flag option which you wish to allow to be negated.
Copyright © 2012–2017. All rights reserved.