Struct Arg

Source
pub struct Arg<'a, T: FromStr + Clone> {
    pub name: String,
    pub description: Option<String>,
    pub value: Option<T>,
    pub completor: Option<Completor<'a>>,
    pub default_value: Option<T>,
}

Fields§

§name: String§description: Option<String>§value: Option<T>§completor: Option<Completor<'a>>§default_value: Option<T>

Implementations§

Source§

impl<'a, T> Arg<'a, T>
where T: FromStr + Clone,

Source

pub fn name(name: &str) -> Self

Source

pub fn default(self, default: T) -> Self

Source

pub fn description(self, description: &str) -> Self

Source

pub fn get(&self) -> T

Source

pub fn completor<F>(self, completor: F) -> Self
where F: FnMut(&str) -> CliResult<Vec<String>> + 'a,

Source§

impl<'a> Arg<'a, String>

Source

pub fn str(name: &str) -> Self

Source§

impl<'a> Arg<'a, i32>

Source

pub fn i32(name: &str) -> Self

Trait Implementations§

Source§

impl<'a, T: Default + FromStr + Clone> Default for Arg<'a, T>

Source§

fn default() -> Arg<'a, T>

Returns the “default value” for a type. Read more
Source§

impl<'a, T: FromStr + Clone> Input for Arg<'a, T>

Source§

fn parse(&mut self, token: &str) -> CliResult<bool>

Source§

fn display_name(&self) -> String

Source§

fn type_name(&self) -> InputType

Source§

fn parsed(&self) -> bool

Source§

fn complete(&mut self, value: &str) -> CliResult<Vec<String>>

must not return completions that don’t start with value, otherwise bash breaks
Source§

fn is_bool_flag(&self) -> bool

Source§

fn description(&self) -> Option<String>

Source§

fn has_default(&self) -> bool

Auto Trait Implementations§

§

impl<'a, T> Freeze for Arg<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for Arg<'a, T>

§

impl<'a, T> !Send for Arg<'a, T>

§

impl<'a, T> !Sync for Arg<'a, T>

§

impl<'a, T> Unpin for Arg<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Arg<'a, T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.