Skip to main content

OptSpec

Struct OptSpec 

Source
pub struct OptSpec<'a, Ctx: ?Sized> { /* private fields */ }
Expand description

Option (flag or value-bearing).

Implementations§

Source§

impl<'a, Ctx: ?Sized> OptSpec<'a, Ctx>

Source

pub fn flag<F>(name: &'a str, cb: F) -> Self
where F: Fn(&mut Ctx) + 'a,

Create a flag option. Other fields are set via builder methods.

Source

pub fn flag_try<F, E>(name: &'a str, cb: F) -> Self
where F: Fn(&mut Ctx) -> Result<(), E> + 'a, E: Error + Send + Sync + 'static,

Create a flag option with a fallible callback.

Source

pub fn value<F>(name: &'a str, cb: F) -> Self
where F: Fn(&OsStr, &mut Ctx) + 'a,

Create a value option. Other fields are set via builder methods.

Source

pub fn value_try<F, E>(name: &'a str, cb: F) -> Self
where F: Fn(&OsStr, &mut Ctx) -> Result<(), E> + 'a, E: Error + Send + Sync + 'static,

Create a value option with a fallible callback.

Source

pub fn short(self, s: char) -> Self

Source

pub fn long(self, l: &'a str) -> Self

Source

pub fn metavar(self, mv: &'a str) -> Self

Source

pub fn help(self, h: &'a str) -> Self

Source

pub fn env(self, name: &'a str) -> Self

Source

pub fn default(self, val: impl Into<OsString>) -> Self

Source

pub fn group(self, g: &'a str) -> Self

Source

pub fn single(self) -> Self

Source

pub fn repeatable(self) -> Self

Source

pub fn validator<F, E>(self, v: F) -> Self
where F: Fn(&OsStr) -> Result<(), E> + 'a, E: Display,

Value validator that returns a displayable error (converted into Error::User).

Source

pub fn validator_try<F, E>(self, v: F) -> Self
where F: Fn(&OsStr) -> Result<(), E> + 'a, E: Error + Send + Sync + 'static,

Value validator that returns a typed error (boxed into Error::UserAny).

Source

pub fn get_name(&self) -> &str

Source

pub fn get_short(&self) -> Option<char>

Source

pub fn get_long(&self) -> Option<&str>

Source

pub fn get_metavar(&self) -> Option<&str>

Source

pub fn get_help(&self) -> Option<&str>

Source

pub fn get_env(&self) -> Option<&str>

Source

pub fn get_default(&self) -> Option<&OsString>

Source

pub fn get_group(&self) -> Option<&str>

Source

pub fn is_value(&self) -> bool

Source

pub fn get_repeat(&self) -> Repeat

Source

pub fn get_on_value(&self) -> Option<&OnValueFn<'a, Ctx>>

Source

pub fn get_on_flag(&self) -> Option<&OnFlagFn<'a, Ctx>>

Source

pub fn get_validator(&self) -> Option<&ValueValidatorFn<'a>>

Auto Trait Implementations§

§

impl<'a, Ctx> Freeze for OptSpec<'a, Ctx>
where Ctx: ?Sized,

§

impl<'a, Ctx> !RefUnwindSafe for OptSpec<'a, Ctx>

§

impl<'a, Ctx> !Send for OptSpec<'a, Ctx>

§

impl<'a, Ctx> !Sync for OptSpec<'a, Ctx>

§

impl<'a, Ctx> Unpin for OptSpec<'a, Ctx>
where Ctx: ?Sized,

§

impl<'a, Ctx> !UnwindSafe for OptSpec<'a, Ctx>

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.