Skip to main content

ResolvedInvocation

Struct ResolvedInvocation 

Source
pub struct ResolvedInvocation { /* private fields */ }
Expand description

One legal invocation, projected onto the shape that matched it.

Read it through the typed accessors — text, flag, integer, source and their optional and repeated forms. Each one checks the read against what the matched combination declares, and a mismatch is an InvocationReadError: a defect in the program, reported as cli_invocation_invalid at exit 1. There is no untyped read, so no handler can mistake “not declared” for a legitimate false or an empty string.

Implementations§

Source§

impl ResolvedInvocation

Source

pub fn command_path(&self) -> &[String]

Source

pub fn action_id(&self) -> &str

Source

pub fn combination_id(&self) -> &str

Source

pub fn output_plan(&self) -> &OutputPlan

Source

pub fn was_explicit( &self, argument_id: &str, ) -> Result<bool, InvocationReadError>

Whether the caller wrote this argument, as opposed to inheriting it from the shape’s fixed value or the argument’s default.

Source

pub fn declares(&self, argument_id: &str) -> bool

Whether the matched combination declares argument_id at all.

For a handler bound to an action several combinations share, where only some of them accept an argument: ask, then read. Reading an undeclared id is still an InvocationReadError.

Source

pub fn text(&self, argument_id: &str) -> Result<&str, InvocationReadError>

A string, enum or UUID value the combination always supplies: required, fixed, or defaulted.

Source

pub fn optional_text( &self, argument_id: &str, ) -> Result<Option<&str>, InvocationReadError>

A string, enum or UUID value the caller may omit.

Source

pub fn texts(&self, argument_id: &str) -> Result<Vec<&str>, InvocationReadError>

Every value of a repeatable string, enum or UUID argument, in argv order.

Source

pub fn flag(&self, argument_id: &str) -> Result<bool, InvocationReadError>

Whether a flag was given. An absent flag the combination declares is a legitimate false; an undeclared one is a read error, never false.

Source

pub fn json_text(&self, argument_id: &str) -> Result<&str, InvocationReadError>

The raw source text of a json argument the combination always supplies.

Source

pub fn optional_json_text( &self, argument_id: &str, ) -> Result<Option<&str>, InvocationReadError>

The raw source text of a json argument the caller may omit.

Source

pub fn integer<T: TryFrom<i64>>( &self, argument_id: &str, ) -> Result<T, InvocationReadError>

An i64 argument converted to the integer type the handler works in.

A value that does not fit T is a read error: the registry’s ArgSpec::range is where the bound belongs, so the caller gets a usage error at exit 2 instead of a handler-side check.

Source

pub fn optional_integer<T: TryFrom<i64>>( &self, argument_id: &str, ) -> Result<Option<T>, InvocationReadError>

An i64 argument the caller may omit, converted as integer.

Source

pub fn integers<T: TryFrom<i64>>( &self, argument_id: &str, ) -> Result<Vec<T>, InvocationReadError>

Every value of a repeatable i64 argument, each converted as integer.

Source

pub fn number(&self, argument_id: &str) -> Result<f64, InvocationReadError>

A finite f64 argument the combination always supplies.

Source

pub fn optional_number( &self, argument_id: &str, ) -> Result<Option<f64>, InvocationReadError>

A finite f64 argument the caller may omit.

Source

pub fn key_value( &self, argument_id: &str, ) -> Result<(&str, &str), InvocationReadError>

A KEY=VALUE argument the combination always supplies, split at the first =.

Source

pub fn optional_key_value( &self, argument_id: &str, ) -> Result<Option<(&str, &str)>, InvocationReadError>

A KEY=VALUE argument the caller may omit.

Source

pub fn key_values( &self, argument_id: &str, ) -> Result<Vec<(&str, &str)>, InvocationReadError>

Every pair of a repeatable KEY=VALUE argument, in argv order.

Source

pub fn source( &self, argument_id: &str, ) -> Result<&ValueSource, InvocationReadError>

Where a sourced argument’s value is, as the parser classified it.

Classification is syntax only: nothing has been read. Call ValueSource::read or read_secret when the value is actually needed, so a variable or file that does not exist is a failure of the command that needed it, not of argv.

Source

pub fn optional_source( &self, argument_id: &str, ) -> Result<Option<&ValueSource>, InvocationReadError>

A sourced argument the caller may omit.

Source

pub fn sources( &self, argument_id: &str, ) -> Result<&[ValueSource], InvocationReadError>

Every source of a repeatable sourced argument, in argv order.

Trait Implementations§

Source§

impl Clone for ResolvedInvocation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolvedInvocation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ResolvedInvocation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResolvedInvocation

Auto Trait Implementations§

§

impl Forget for ResolvedInvocation

§

impl Freeze for ResolvedInvocation
where *const u8 is !null: Freeze, PhantomData<String>: Freeze, PhantomData<u8>: Freeze, *const LeafNode<String, InvocationValue> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, InvocationValue)>>: Freeze, *const LeafNode<String, Vec<ValueSource>> is !null: Freeze, PhantomData<Box<(String, Vec<ValueSource>)>>: Freeze, *const LeafNode<String, DeclaredArgument> is !null: Freeze, PhantomData<Box<(String, DeclaredArgument)>>: Freeze, *const LeafNode<String, SetValZST> is !null: Freeze, PhantomData<Box<(String, SetValZST)>>: Freeze,

§

impl Move for ResolvedInvocation

§

impl RefUnwindSafe for ResolvedInvocation

§

impl Send for ResolvedInvocation
where RawVecInner: Send, NodeRef<Owned, String, InvocationValue, LeafOrInternal>: Send, BoxRaw<(String, InvocationValue)>: Send, NodeRef<Owned, String, Vec<ValueSource>, LeafOrInternal>: Send, BoxRaw<(String, Vec<ValueSource>)>: Send, NodeRef<Owned, String, DeclaredArgument, LeafOrInternal>: Send, BoxRaw<(String, DeclaredArgument)>: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send,

§

impl Sync for ResolvedInvocation
where RawVecInner: Sync, NodeRef<Owned, String, InvocationValue, LeafOrInternal>: Sync, BoxRaw<(String, InvocationValue)>: Sync, NodeRef<Owned, String, Vec<ValueSource>, LeafOrInternal>: Sync, BoxRaw<(String, Vec<ValueSource>)>: Sync, NodeRef<Owned, String, DeclaredArgument, LeafOrInternal>: Sync, BoxRaw<(String, DeclaredArgument)>: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync,

§

impl Unpin for ResolvedInvocation
where *const u8 is !null: Unpin, *const LeafNode<String, InvocationValue> is !null: Unpin, Box<(String, InvocationValue)>: Unpin, *const LeafNode<String, Vec<ValueSource>> is !null: Unpin, Box<(String, Vec<ValueSource>)>: Unpin, *const LeafNode<String, DeclaredArgument> is !null: Unpin, Box<(String, DeclaredArgument)>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin,

§

impl UnsafeUnpin for ResolvedInvocation
where *const u8 is !null: UnsafeUnpin, PhantomData<String>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, InvocationValue> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, InvocationValue)>>: UnsafeUnpin, *const LeafNode<String, Vec<ValueSource>> is !null: UnsafeUnpin, PhantomData<Box<(String, Vec<ValueSource>)>>: UnsafeUnpin, *const LeafNode<String, DeclaredArgument> is !null: UnsafeUnpin, PhantomData<Box<(String, DeclaredArgument)>>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin,

§

impl UnwindSafe for ResolvedInvocation
where RawVecInner: UnwindSafe, BTreeMap<String, InvocationValue>: UnwindSafe, BTreeMap<String, Vec<ValueSource>>: UnwindSafe, BTreeMap<String, DeclaredArgument>: UnwindSafe, BTreeMap<String, SetValZST>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more