pub struct ParsedCommand {
pub command: Word,
pub args: Vec<CommandArg>,
}Expand description
Structurally decomposed command with arguments in source order.
Schema-free parse: flags are identified syntactically (tokens starting
with -). Without a command’s flag definitions, --flag value is
ambiguous — the value appears as a separate positional. Schema-aware
consumers walk args to associate values with flags they know about.
Fields§
§command: WordBase command name (path stripped, env vars skipped).
args: Vec<CommandArg>Arguments in source order — flags and positionals interleaved.
Implementations§
Source§impl ParsedCommand
impl ParsedCommand
Sourcepub fn from_words(words: &[Word]) -> Self
pub fn from_words(words: &[Word]) -> Self
Construct a ParsedCommand directly from a word slice, avoiding a
string round-trip through shlex.
- First word that is not an env assignment becomes the
command(with path prefix stripped). - Remaining words are classified as
CommandArg::FlagorCommandArg::Positionalusing the same schema-free rules asparse_command.
Sourcepub fn subcommand(&self) -> Option<&str>
pub fn subcommand(&self) -> Option<&str>
First positional argument (often a subcommand).
Sourcepub fn flags(&self) -> impl Iterator<Item = &ParsedFlag>
pub fn flags(&self) -> impl Iterator<Item = &ParsedFlag>
Iterate over all flags.
Sourcepub fn positional(&self) -> impl Iterator<Item = &str>
pub fn positional(&self) -> impl Iterator<Item = &str>
Iterate over all positional arguments.
Trait Implementations§
Source§impl Clone for ParsedCommand
impl Clone for ParsedCommand
Source§fn clone(&self) -> ParsedCommand
fn clone(&self) -> ParsedCommand
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParsedCommand
impl Debug for ParsedCommand
impl Eq for ParsedCommand
Source§impl PartialEq for ParsedCommand
impl PartialEq for ParsedCommand
Source§fn eq(&self, other: &ParsedCommand) -> bool
fn eq(&self, other: &ParsedCommand) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ParsedCommand
Auto Trait Implementations§
impl Freeze for ParsedCommand
impl RefUnwindSafe for ParsedCommand
impl Send for ParsedCommand
impl Sync for ParsedCommand
impl Unpin for ParsedCommand
impl UnsafeUnpin for ParsedCommand
impl UnwindSafe for ParsedCommand
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
Mutably borrows from an owned value. Read more