#[non_exhaustive]pub enum TokenRole {
Show 13 variants
Program,
Command {
name: String,
},
Flag {
flag: Arc<SpecFlag>,
spelling: String,
negated: bool,
},
Value {
flag: Arc<SpecFlag>,
values: Vec<String>,
attached: bool,
},
Arg {
arg: Arc<SpecArg>,
values: Vec<String>,
},
Separator,
Builtin {
spelling: String,
},
ValueTerminator {
ends: String,
},
Restart,
UnknownFlag {
bound_as: Option<Arc<SpecArg>>,
},
Refused {
reason: String,
},
External,
Unread,
}Expand description
What one word of the command line became.
Several because a single token can do more than one thing: -abc sets three flags,
-j8 is a flag and its value.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Program
argv[0]. Also a Command when a multicall symlink makes the basename a word.
Command
Selected a subcommand.
Flag
Named a flag, in this spelling. negated for the negate form.
Value
Supplied a flag’s value. Several values when a delimiter split the word.
Fields
Arg
Filled a positional argument. Several values when a delimiter split the word.
Separator
An explicit --, consumed as a separator.
Builtin
A word the parser answers itself rather than binding: --help, -h, --version,
-V. The parse stops here and the answer travels as an error carrying the text, so
without a role the word reads as having done nothing while a whole help page arrives
in the error list.
ValueTerminator
A declared value_terminator, consumed to end a run of values. ends names the
declaration whose run it closed — the word is not one of that run’s values, which is
the whole reason it was declared.
Restart
A declared restart_token: the positional cursor and the values it had filled start
over here. Recorded because the words before it are still in the report, and without
this row they look like they filled arguments that then came back empty.
UnknownFlag
A flag-like word no declaration matched. bound_as is the positional that took it
under unknown_flags="value", and None when the word was refused.
Refused
The word reached a declaration that would not take it, and was dropped. Without this the token reads as having done nothing, which is the one thing it did not do.
External
Forwarded to an external subcommand.
Unread
The parser stopped before this word — a help request, a refused value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokenRole
impl RefUnwindSafe for TokenRole
impl Send for TokenRole
impl Sync for TokenRole
impl Unpin for TokenRole
impl UnsafeUnpin for TokenRole
impl UnwindSafe for TokenRole
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more