Skip to main content

Cmd

Struct Cmd 

Source
pub struct Cmd<C> { /* private fields */ }
Expand description

A named subcommand (or the implicit root command).

Options registered on a Cmd are only matched when that subcommand is active. The root Cmd is always active.

Implementations§

Source§

impl<C: 'static> Cmd<C>

Source

pub fn add_option<T, F>(&mut self, names: &str, field: F, description: &str)
where T: ParseCliValue + 'static, F: Fn(&mut C) -> &mut T + Clone + 'static,

Register a named option that writes through a field accessor.

names is a comma-separated list of aliases, e.g. "-s,--steps".

Source

pub fn add_flag<F>(&mut self, names: &str, field: F, description: &str)
where F: Fn(&mut C, bool) + Clone + 'static,

Register a bool flag (no value argument; presence sets true).

Source

pub fn add_multi<F>(&mut self, names: &str, field: F, description: &str)
where F: Fn(&mut C) -> &mut Vec<String> + Clone + 'static,

Register a multi-option that appends to a Vec<String>.

Source

pub fn add_positional<T, F>( &mut self, name: &str, field: F, description: &str, required: bool, )
where T: ParseCliValue + 'static, F: Fn(&mut C) -> &mut T + Clone + 'static,

Register a positional argument.

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for Cmd<C>

§

impl<C> !Send for Cmd<C>

§

impl<C> !Sync for Cmd<C>

§

impl<C> !UnwindSafe for Cmd<C>

§

impl<C> Forget for Cmd<C>

§

impl<C> Freeze for Cmd<C>
where Vec<Opt<C>>: Freeze,

§

impl<C> Move for Cmd<C>

§

impl<C> Unpin for Cmd<C>
where Vec<Opt<C>>: Unpin,

§

impl<C> UnsafeUnpin for Cmd<C>
where Vec<Opt<C>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.