public final class Parser
extends java.lang.Object
Command
.Modifier and Type | Class and Description |
---|---|
static class |
Parser.Argument
A command line argument.
|
static class |
Parser.Arity
Defines the arity of an argument.
|
static class |
Parser.Builder
Builds an
Parser . |
Modifier and Type | Method and Description |
---|---|
static Parser.Builder |
builder() |
java.util.List<Parser.Argument> |
getArgs() |
java.util.Optional<java.lang.String> |
getPositionalHelp() |
java.util.Optional<java.lang.String> |
getPositionalName() |
Arguments |
parse(java.lang.String[] args)
Parses command line arguments in an
Arguments object. |
Arguments |
parse(java.lang.String[] args,
int offset)
Parses command line arguments in an
Arguments object. |
public static Parser.Builder builder()
public java.util.Optional<java.lang.String> getPositionalName()
public java.util.Optional<java.lang.String> getPositionalHelp()
public java.util.List<Parser.Argument> getArgs()
public Arguments parse(java.lang.String[] args)
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.
args
- Arguments to parse.CliError
- if the arguments are invalid.public Arguments parse(java.lang.String[] args, int offset)
Arguments
object.args
- Arguments to parse.offset
- Number of arguments to skip before parsing.CliError
- if the arguments are invalid.parse(String[])