Class Parser

java.lang.Object
software.amazon.smithy.cli.Parser

public final class Parser extends Object
Defines the CLI argument parser of a Command.
  • Method Details

    • builder

      public static Parser.Builder builder()
    • getPositionalName

      public Optional<String> getPositionalName()
    • getPositionalHelp

      public Optional<String> getPositionalHelp()
    • getArgs

      public List<Parser.Argument> getArgs()
    • parse

      public Arguments parse(String[] args)
      Parses command line arguments in an Arguments object.

      All arguments after the first argument that does not start with "-" or after "--" are treated as positional options. Arguments that come before this must be present in the argument spec returned by the command. Any encountered unknown argument will throw an exception. Arguments that expect a value and do not find one will throw an exception.

      Parameters:
      args - Arguments to parse.
      Returns:
      Returns the parsed arguments.
      Throws:
      CliError - if the arguments are invalid.
    • parse

      public Arguments parse(String[] args, int offset)
      Parses command line arguments in an Arguments object.
      Parameters:
      args - Arguments to parse.
      offset - Number of arguments to skip before parsing.
      Returns:
      Returns the parsed arguments.
      Throws:
      CliError - if the arguments are invalid.
      See Also: