Annotation Type Parser
-
@Target(TYPE) @Retention(RUNTIME) @Documented public @interface ParserClass annotation used to declaratively specify a parser configurationWhen applied to a class that is also annotated with the
Commandannotation then if that class is used withSingleCommand.singleCommand(Class)the parser configuration will automatically be detected from this annotation.When specifying a CLI via the
Cliannotation then this annotation may be included as an argument to theCli.parserConfiguration()field to provide a parser configuration for the CLI.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Alias[]aliasesDefines command aliasescharaliasesForceBuiltInPrefixSets a character used in alias definitions to indicate that the built-in should be called regardless of the setting ofaliasesOverrideBuiltIns()booleanaliasesMayChainControls whether command alises may be chained i.e.booleanaliasesOverrideBuiltInsControls whether aliases are allowed to override built-in commands i.e.booleanallowCommandAbbreviationControls whether command names may be abbreviated provided such abbreviations are unambiguous (default false)booleanallowOptionAbbreviationControls whether options names may be abbreviated provided such abbreviations are unambiguous (default false)java.lang.StringargumentsSeparatorControls the separator that is used to distinguish options from arguments were arguments may be confused as optionsjava.lang.Class<? extends CommandFactory>commandFactorySets the command factory class to usejava.lang.String[]compositionAnnotationClassesSets the composition annotation classes to use.booleandefaultAliasLocatorsFirstSets whether to use the default alias locators first before any additional alias locators that may be defined (default false)booleandefaultParsersFirstSets whether to use the default option parsers first before any additional option parsers that may be defined (default true)java.lang.Class<? extends ParserErrorHandler>errorHandlerSets the error handler to use, defaults toFailFastwhich throws errors as soon as they are encounteredjava.lang.StringflagNegationPrefixSets the flag negation prefixjava.lang.Class<? extends NumericTypeConverter>numericTypeConverterSets the numeric type converter to use, this is used in conjunction with the value of thetypeConverter(), if that class does not respectNumericTypeConverterinstances then this field has no effectjava.lang.Class<? extends OptionParser>[]optionParsersSets the option parser classes to be usedjava.lang.Class<? extends TypeConverter>typeConverterSets the type converter class to usebooleanuseDefaultAliasLocatorsSets whether to use the default user alias locators (default true)booleanuseDefaultOptionParsersSets whether to use the default set of option parsers (default true)java.lang.StringuserAliasesFileDefines the name of a file from which user defined command aliases should be readjava.lang.StringuserAliasesPrefixSets the prefix used for properties that define aliasesjava.lang.String[]userAliasesSearchLocationDefines the search locations (i.e.java.lang.Class<? extends ResourceLocator>[]userAliasLocatorsSets the user alias locator classes to be used
-
-
-
-
aliasesOverrideBuiltIns
boolean aliasesOverrideBuiltIns
Controls whether aliases are allowed to override built-in commands i.e. if a command and an alias are defined with the same name does the alias take precedence (default false)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
- Returns:
- True if aliases may override built-ins, false otherwise
- Default:
- false
-
-
-
aliases
Alias[] aliases
Defines command aliases- Returns:
- Command aliases
- Default:
- {}
-
-
-
userAliasesSearchLocation
java.lang.String[] userAliasesSearchLocation
Defines the search locations (i.e. directories) where the properties file containing the user defined aliases may existThese 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- Returns:
- Search locations for alises
- Default:
- {""}
-
-
-
userAliasesPrefix
java.lang.String userAliasesPrefix
Sets the prefix used for properties that define aliasesThis 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 propertyfoo.barthen you would be defining an aliasbar- Returns:
- User defined aliases prefix
- Default:
- ""
-
-
-
aliasesForceBuiltInPrefix
char aliasesForceBuiltInPrefix
Sets a character used in alias definitions to indicate that the built-in should be called regardless of the setting ofaliasesOverrideBuiltIns()This is useful since it allows users to redefine built-ins with their desired default arguments while still allowing the alias to call the original built-in. This defaults to
!- Returns:
- Aliases force built-in prefix character
- Default:
- '!'
-
-
-
userAliasLocators
java.lang.Class<? extends ResourceLocator>[] userAliasLocators
Sets the user alias locator classes to be used- Returns:
- User alias locator classes
- Default:
- {}
-
-
-
optionParsers
java.lang.Class<? extends OptionParser>[] optionParsers
Sets the option parser classes to be used- Returns:
- Option parser classes
- Default:
- {}
-
-
-
commandFactory
java.lang.Class<? extends CommandFactory> commandFactory
Sets the command factory class to use- Returns:
- Command factory class
- Default:
- com.github.rvesse.airline.DefaultCommandFactory.class
-
-
-
compositionAnnotationClasses
java.lang.String[] compositionAnnotationClasses
Sets the composition annotation classes to use.This is set by providing the fully qualified names of the classes, rather than class references themselves, this allows Airline to dynamically load the annotation at the point where it collects metadata for classes. Thus allowing the actual annotation types used to themselves be injected at runtime rather than compile time.
See
MetadataLoader.loadInjectionMetadata(Class, ParserMetadata)for more detailed description of how this configuration is used.This configuration point was introduced in 2.9.0 as part of the introduction of the
AirlineModuleannotation to provide for backwards compatibility and for users to better integrate with their chosen dependency injection framework.- Returns:
- Composition annotation classes
- Since:
- 2.9.0
- Default:
- {}
-
-
-
typeConverter
java.lang.Class<? extends TypeConverter> typeConverter
Sets the type converter class to use- Returns:
- Type converter class
- Default:
- com.github.rvesse.airline.types.DefaultTypeConverter.class
-
-
-
numericTypeConverter
java.lang.Class<? extends NumericTypeConverter> numericTypeConverter
Sets the numeric type converter to use, this is used in conjunction with the value of thetypeConverter(), if that class does not respectNumericTypeConverterinstances then this field has no effect- Returns:
- Numeric type converter class
- Default:
- com.github.rvesse.airline.types.numerics.DefaultNumericConverter.class
-
-
-
errorHandler
java.lang.Class<? extends ParserErrorHandler> errorHandler
Sets the error handler to use, defaults toFailFastwhich throws errors as soon as they are encountered- Returns:
- Error handler to use
- Default:
- com.github.rvesse.airline.parser.errors.handlers.FailFast.class
-
-
-
flagNegationPrefix
java.lang.String flagNegationPrefix
Sets the flag negation prefixIf set flag options (those with arity zero) will have their value set to
falseif 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 tofalse. Note that an appropriate name must be present in theOption.name()for the flag option which you wish to allow to be negated.- Returns:
- Flag negation prefix
- Default:
- ""
-
-