#[non_exhaustive]pub struct ParseOutput {Show 15 fields
pub cmd: SpecCommand,
pub cmds: Vec<SpecCommand>,
pub args: IndexMap<Arc<SpecArg>, ParseValue>,
pub flags: IndexMap<Arc<SpecFlag>, ParseValue>,
pub tokens: Vec<TokenBinding>,
pub flag_origins: IndexMap<Arc<SpecFlag>, Vec<ValueOrigin>>,
pub arg_origins: IndexMap<Arc<SpecArg>, Vec<ValueOrigin>>,
pub overridden_flags: BTreeMap<String, String>,
pub available_flags: BTreeMap<String, Arc<SpecFlag>>,
pub flag_awaiting_value: Vec<Arc<SpecFlag>>,
pub errors: Vec<UsageErr>,
pub warnings: Vec<Warning>,
pub next_arg: Option<Arc<SpecArg>>,
pub double_dash_seen: bool,
pub external: Option<Vec<String>>,
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cmd: SpecCommand§cmds: Vec<SpecCommand>§args: IndexMap<Arc<SpecArg>, ParseValue>§flags: IndexMap<Arc<SpecFlag>, ParseValue>§tokens: Vec<TokenBinding>What each word of the command line became, in argv order, one entry per word.
The token half of provenance; ParseOutput::flag_origins and
ParseOutput::arg_origins are the other half. A table keyed by token cannot show
a value that came from nowhere in argv, and a table keyed by declaration cannot show
a token that bound to nothing, so both exist.
flag_origins: IndexMap<Arc<SpecFlag>, Vec<ValueOrigin>>Where a flag’s value came from when it did not come from argv, in the order the
fallbacks fired. Keyed as ParseOutput::flags is.
A list rather than one origin: repeated bare occurrences of a var flag each take a
default_missing value, so one flag can have several.
arg_origins: IndexMap<Arc<SpecArg>, Vec<ValueOrigin>>Where an argument’s value came from when it did not come from argv. Keyed as
ParseOutput::args is.
overridden_flags: BTreeMap<String, String>Flags a later occurrence removed, and the flag that removed them.
The overriding name is the half a caller needs: the fallback phase silently declines
to fill an overridden flag, so “why is --quiet unset when its default says
otherwise” has no answer without it.
available_flags: BTreeMap<String, Arc<SpecFlag>>Every flag the parser recognizes at this point, keyed by each of its aliases
(--long, -s, negations).
This includes flags that only remain recognized because they may appear before a
mounted command — see ParseOutput::completion_flags for the set a completion
should offer.
flag_awaiting_value: Vec<Arc<SpecFlag>>§errors: Vec<UsageErr>§warnings: Vec<Warning>Deprecated declarations this command line used, for the caller to render when its
logging is up. Empty from parse_partial: a half-typed line being completed has
not used anything yet.
next_arg: Option<Arc<SpecArg>>The positional argument the next word would have filled, i.e. where the parser’s
cursor stopped. None once every argument is satisfied.
Completions need exactly this: the parser already accounts for var_max, for
restart_token rewinds, and for the jump an explicit -- performs onto a
double_dash="required" argument, so re-deriving it from args would disagree.
double_dash_seen: boolWhether an explicit -- was consumed as a separator.
A -- that double_dash="preserve" keeps as a value does not count: it is a value
of the variadic argument collecting it, not a separator, so it does not unlock a
double_dash="required" argument.
external: Option<Vec<String>>Remaining argv captured when an unmatched word was forwarded as an external subcommand: the command name first, then every token after it.
Absent when no external command was selected. See SpecCommand::external_subcommand.
Implementations§
Source§impl ParseOutput
impl ParseOutput
Sourcepub fn completion_flags(&self) -> BTreeMap<String, Arc<SpecFlag>>
pub fn completion_flags(&self) -> BTreeMap<String, Arc<SpecFlag>>
The flags a completion should offer for the parsed command.
Usually every recognized flag, i.e. ParseOutput::available_flags. Once a mounted
command has been reached, though, the commands above it belong to the mounting CLI and
their flags are not accepted there — mise, for example, forwards everything after a task
name to the task itself — so only the flags declared from the mount boundary down are
offered. Those globals stay in available_flags because they may legitimately appear
before the mounted command.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ParseOutput
impl !RefUnwindSafe for ParseOutput
impl !UnwindSafe for ParseOutput
impl Send for ParseOutput
impl Sync for ParseOutput
impl Unpin for ParseOutput
impl UnsafeUnpin for ParseOutput
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> 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