Class SingleCommand<C>

java.lang.Object
com.github.rvesse.airline.SingleCommand<C>
Type Parameters:
C - Command type

public class SingleCommand<C> extends Object
Class for encapsulating and parsing single commands
  • Field Details

  • Constructor Details

  • Method Details

    • singleCommand

      public static <C> SingleCommand<C> singleCommand(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(Class<C> command, ParserMetadata<C> parserConfig)
      Creates a new single command
      Type Parameters:
      C - Command type we wish to parse to
      Parameters:
      command - Command class
      parserConfig - Parser configuration to use, if null the default configuration is used
      Returns:
      Single command parser
    • createRestrictions

      private List<GlobalRestriction> createRestrictions(Class<C> commandClass, 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(String... args)
      Parses the arguments to produce a command instance
      Parameters:
      args - Arguments
      Returns:
      Command instance
    • parse

      public C parse(Iterable<String> args)
      Parses the arguments to produce a command instance
      Parameters:
      args - Arguments
      Returns:
      Command instance
    • parseWithResult

      public ParseResult<C> parseWithResult(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(Iterable<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