pub struct ParsedArgs(/* private fields */);Expand description
Parsed command arguments, passed to crate::executor::CommandHandler::execute
and crate::executor::AsyncCommandHandler::execute
Wraps the output of CliParser::parse_typed, exposing typed accessors
so handlers never need to match on ParsedValue directly. Introduced
in v0.6.0 (DD-024, #39) to replace &HashMap<String, String>, which
could not represent repeatable options.
Lives directly in parser rather than nested under cli_parser: it is
the shared type consumed by every handler regardless of dispatch path
(CLI one-shot via CliParser::parse_typed, or REPL via
ParsedArgs::from_scalars) — not a CLI-specific detail.
§Example
use dynamic_cli::parser::ParsedArgs;
let args = ParsedArgs::from_scalars(
[("name".to_string(), "World".to_string())].into_iter().collect(),
);
assert_eq!(args.get_scalar("name"), Some("World"));
assert_eq!(args.get_scalar("missing"), None);Implementations§
Source§impl ParsedArgs
impl ParsedArgs
Sourcepub fn new(values: HashMap<String, ParsedValue>) -> Self
pub fn new(values: HashMap<String, ParsedValue>) -> Self
Wrap an already-typed result, as produced by CliParser::parse_typed
Sourcepub fn from_scalars(values: HashMap<String, String>) -> Self
pub fn from_scalars(values: HashMap<String, String>) -> Self
Build a scalar-only ParsedArgs from a plain HashMap<String, String>
Every entry becomes a ParsedValue::Scalar; there is no way to
represent ParsedValue::Repeated through this constructor.
Used by the REPL dispatch path (interface/repl.rs), which relies
on crate::parser::repl_parser::ReplParser::parse_line — itself
untouched by DD-024, since repeatable options have no interactive
REPL-typing use case (see DESIGN_DECISIONS.md, DD-024 addendum,
2026-07-24). Batch/scripted invocations are expected to go through
CliParser::parse_typed directly instead (see issue #41,
ScriptLoaderPlugin).
Sourcepub fn get_scalar(&self, name: &str) -> Option<&str>
pub fn get_scalar(&self, name: &str) -> Option<&str>
Get a scalar argument or option value by name
Returns None both when the name is absent and when it is present
but holds a ParsedValue::Repeated value — mirroring
HashMap::get’s silent-on-absence semantics rather than
distinguishing “wrong kind” from “missing”.
Sourcepub fn get_repeated(&self, name: &str) -> Option<&[OptionOccurrence]>
pub fn get_repeated(&self, name: &str) -> Option<&[OptionOccurrence]>
Get every occurrence of a repeatable option by name
Returns None both when the name is absent and when it is present
but holds a ParsedValue::Scalar value — same silent-on-absence
contract as Self::get_scalar.
Sourcepub fn to_scalar_map(&self) -> HashMap<String, String>
pub fn to_scalar_map(&self) -> HashMap<String, String>
Collapse back down to a scalar-only HashMap<String, String>
Every ParsedValue::Scalar entry is kept as-is; any
ParsedValue::Repeated entry is silently dropped — mirroring the
same “no consumer yet” rationale as Self::from_scalars (see the
DD-024 addendum in DESIGN_DECISIONS.md). Used at the boundary of
subsystems that predate DD-024 and have not been extended to
understand repeatable options, e.g. the WASM plugin ABI
([crate::plugin::wasm::WasmHandler]), which serializes arguments
as flat HashMap<String, String> to the guest.
Trait Implementations§
Source§impl Clone for ParsedArgs
impl Clone for ParsedArgs
Source§fn clone(&self) -> ParsedArgs
fn clone(&self) -> ParsedArgs
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParsedArgs
impl Debug for ParsedArgs
Source§impl Default for ParsedArgs
impl Default for ParsedArgs
Source§fn default() -> ParsedArgs
fn default() -> ParsedArgs
Source§impl PartialEq for ParsedArgs
impl PartialEq for ParsedArgs
impl StructuralPartialEq for ParsedArgs
Auto Trait Implementations§
impl Freeze for ParsedArgs
impl RefUnwindSafe for ParsedArgs
impl Send for ParsedArgs
impl Sync for ParsedArgs
impl Unpin for ParsedArgs
impl UnsafeUnpin for ParsedArgs
impl UnwindSafe for ParsedArgs
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