- java.lang.Object
-
- com.github.rvesse.airline.SingleCommand<C>
-
- Type Parameters:
C
- Command type
public class SingleCommand<C> extends java.lang.Object
Class for encapsulating and parsing single commands
-
-
Field Summary
Fields Modifier and Type Field Description private CommandMetadata
commandMetadata
private ParserMetadata<C>
parserConfig
private java.util.List<GlobalRestriction>
restrictions
-
Constructor Summary
Constructors Modifier Constructor Description private
SingleCommand(java.lang.Class<C> command, java.lang.Iterable<GlobalRestriction> restrictions, ParserMetadata<C> parserConfig)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<GlobalRestriction>
createRestrictions(java.lang.Class<C> commandClass, java.lang.Iterable<GlobalRestriction> restrictions)
CommandMetadata
getCommandMetadata()
Gets the command metadataParserMetadata<C>
getParserConfiguration()
Gets the parser configurationC
parse(java.lang.Iterable<java.lang.String> args)
Parses the arguments to produce a command instanceC
parse(java.lang.String... args)
Parses the arguments to produce a command instanceParseResult<C>
parseWithResult(java.lang.Iterable<java.lang.String> args)
Parses the arguments to produce a result.ParseResult<C>
parseWithResult(java.lang.String... args)
Parses the arguments to produce a result.static <C> SingleCommand<C>
singleCommand(java.lang.Class<C> command)
Creates a new single commandstatic <C> SingleCommand<C>
singleCommand(java.lang.Class<C> command, ParserMetadata<C> parserConfig)
Creates a new single command
-
-
-
Field Detail
-
parserConfig
private final ParserMetadata<C> parserConfig
-
commandMetadata
private final CommandMetadata commandMetadata
-
restrictions
private final java.util.List<GlobalRestriction> restrictions
-
-
Constructor Detail
-
SingleCommand
private SingleCommand(java.lang.Class<C> command, java.lang.Iterable<GlobalRestriction> restrictions, ParserMetadata<C> parserConfig)
-
-
Method Detail
-
singleCommand
public static <C> SingleCommand<C> singleCommand(java.lang.Class<C> command)
Creates a new single command- Type Parameters:
C
- Command type we wish to parse to- Parameters:
command
- Command class- Returns:
- Single command parser
-
singleCommand
public static <C> SingleCommand<C> singleCommand(java.lang.Class<C> command, ParserMetadata<C> parserConfig)
Creates a new single command- Type Parameters:
C
- Command type we wish to parse to- Parameters:
command
- Command classparserConfig
- Parser configuration to use, ifnull
the default configuration is used- Returns:
- Single command parser
-
createRestrictions
private java.util.List<GlobalRestriction> createRestrictions(java.lang.Class<C> commandClass, java.lang.Iterable<GlobalRestriction> restrictions)
-
getCommandMetadata
public CommandMetadata getCommandMetadata()
Gets the command metadata- Returns:
- Command metadata
-
getParserConfiguration
public ParserMetadata<C> getParserConfiguration()
Gets the parser configuration- Returns:
- Parser configuration
-
parse
public C parse(java.lang.String... args)
Parses the arguments to produce a command instance- Parameters:
args
- Arguments- Returns:
- Command instance
-
parse
public C parse(java.lang.Iterable<java.lang.String> args)
Parses the arguments to produce a command instance- Parameters:
args
- Arguments- Returns:
- Command instance
-
parseWithResult
public ParseResult<C> parseWithResult(java.lang.String... args)
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
public ParseResult<C> parseWithResult(java.lang.Iterable<java.lang.String> args)
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
-
-