Struct Flag

Source
pub struct Flag<'a, T: Default + FromStr + Clone> {
    pub name: String,
    pub description: Option<String>,
    pub value: Option<T>,
    pub bool_flag: bool,
    pub completor: Option<Completor<'a>>,
}

Fields§

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

Implementations§

Source§

impl<'a> Flag<'a, bool>

Source

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

Source§

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

Source

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

Source

pub fn get(&self) -> T

Source

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

Source

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

Trait Implementations§

Source§

impl<'a, T: FromStr + Default + Clone> Input for Flag<'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 Flag<'a, T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

impl<'a, T> !UnwindSafe for Flag<'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.