Class SingleCommand<C>
java.lang.Object
com.github.rvesse.airline.SingleCommand<C>
- Type Parameters:
C- Command type
Class for encapsulating and parsing single commands
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CommandMetadataprivate final ParserMetadata<C> private final List<GlobalRestriction> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSingleCommand(Class<C> command, Iterable<GlobalRestriction> restrictions, ParserMetadata<C> parserConfig) -
Method Summary
Modifier and TypeMethodDescriptionprivate List<GlobalRestriction> createRestrictions(Class<C> commandClass, Iterable<GlobalRestriction> restrictions) Gets the command metadataGets the parser configurationParses the arguments to produce a command instanceParses the arguments to produce a command instanceparseWithResult(Iterable<String> args) Parses the arguments to produce a result.parseWithResult(String... args) Parses the arguments to produce a result.static <C> SingleCommand<C> singleCommand(Class<C> command) Creates a new single commandstatic <C> SingleCommand<C> singleCommand(Class<C> command, ParserMetadata<C> parserConfig) Creates a new single command
-
Field Details
-
parserConfig
-
commandMetadata
-
restrictions
-
-
Constructor Details
-
SingleCommand
private SingleCommand(Class<C> command, Iterable<GlobalRestriction> restrictions, ParserMetadata<C> parserConfig)
-
-
Method Details
-
singleCommand
Creates a new single command- Type Parameters:
C- Command type we wish to parse to- Parameters:
command- Command class- Returns:
- Single command parser
-
singleCommand
Creates a new single command- Type Parameters:
C- Command type we wish to parse to- Parameters:
command- Command classparserConfig- Parser configuration to use, ifnullthe default configuration is used- Returns:
- Single command parser
-
createRestrictions
private List<GlobalRestriction> createRestrictions(Class<C> commandClass, Iterable<GlobalRestriction> restrictions) -
getCommandMetadata
-
getParserConfiguration
Gets the parser configuration- Returns:
- Parser configuration
-
parse
-
parse
-
parseWithResult
Parses the arguments to produce a result. The result can be inspected to see errors (assuming a suitable error handler was used e.g.CollectAll) and to get a command instance- Parameters:
args- Arguments- Returns:
- Parse result
-
parseWithResult
Parses the arguments to produce a result. The result can be inspected to see errors (assuming a suitable error handler was used e.g.CollectAll) and to get a command instance- Parameters:
args- Arguments- Returns:
- Parse result
-