pub enum ParseError {
NoCommand,
Resolve(ResolveError),
MissingArgument(String),
UnexpectedArgument(String),
MissingFlag(String),
FlagMissingValue {
name: String,
},
UnknownFlag(String),
UnknownSubcommand {
parent: String,
got: String,
},
InvalidChoice {
flag: String,
value: String,
choices: Vec<String>,
},
MutuallyExclusive {
flags: Vec<String>,
},
}Expand description
Errors produced by Parser::parse.
Variants§
NoCommand
The argv slice was empty — no command name was provided.
Resolve(ResolveError)
The command (or subcommand) token could not be resolved.
Wraps a ResolveError transparently so callers can match on
ResolveError::Unknown and ResolveError::Ambiguous directly.
MissingArgument(String)
A required positional argument was not supplied.
The inner String is the argument’s canonical name.
UnexpectedArgument(String)
More positional arguments were supplied than the command declares.
The inner String is the first unexpected token.
MissingFlag(String)
A required flag was not supplied, and no environment-variable fallback
(registered with crate::FlagBuilder::env) provided a value.
The inner String is the flag’s long name (without --).
FlagMissingValue
A value-taking flag was provided without a following value.
UnknownFlag(String)
A flag token (--name or -c) was not recognized by the resolved
command.
The inner String includes the leading dashes, e.g. "--foo" or
"-x". This variant is also raised when --no-{name} negation syntax
is used with an unknown flag name or with a value-taking flag (which
cannot be negated).
UnknownSubcommand
A word token following a subcommand-only parent did not match any declared subcommand.
Only raised when the parent command has no positional arguments defined; otherwise the word is treated as a positional value.
Fields
InvalidChoice
A flag value was provided that is not in the flag’s allowed choices.
Fields
MutuallyExclusive
Two or more mutually exclusive flags were provided in the same invocation.
The flags field lists the conflicting flags (with -- prefix).