pub struct OptSpec<'a, Ctx: ?Sized> { /* private fields */ }Expand description
Option (flag or value-bearing).
Implementations§
Source§impl<'a, Ctx: ?Sized> OptSpec<'a, Ctx>
impl<'a, Ctx: ?Sized> OptSpec<'a, Ctx>
Sourcepub fn flag<F>(name: &'a str, cb: F) -> Self
pub fn flag<F>(name: &'a str, cb: F) -> Self
Create a flag option. Other fields are set via builder methods.
Sourcepub fn flag_try<F, E>(name: &'a str, cb: F) -> Self
pub fn flag_try<F, E>(name: &'a str, cb: F) -> Self
Create a flag option with a fallible callback.
Sourcepub fn value<F>(name: &'a str, cb: F) -> Self
pub fn value<F>(name: &'a str, cb: F) -> Self
Create a value option. Other fields are set via builder methods.
Sourcepub fn value_try<F, E>(name: &'a str, cb: F) -> Self
pub fn value_try<F, E>(name: &'a str, cb: F) -> Self
Create a value option with a fallible callback.
pub fn short(self, s: char) -> Self
pub fn long(self, l: &'a str) -> Self
pub fn metavar(self, mv: &'a str) -> Self
pub fn help(self, h: &'a str) -> Self
pub fn env(self, name: &'a str) -> Self
pub fn default(self, val: impl Into<OsString>) -> Self
pub fn group(self, g: &'a str) -> Self
pub fn single(self) -> Self
pub fn repeatable(self) -> Self
Sourcepub fn validator<F, E>(self, v: F) -> Self
pub fn validator<F, E>(self, v: F) -> Self
Value validator that returns a displayable error (converted into Error::User).
Sourcepub fn validator_try<F, E>(self, v: F) -> Self
pub fn validator_try<F, E>(self, v: F) -> Self
Value validator that returns a typed error (boxed into Error::UserAny).
pub fn get_name(&self) -> &str
pub fn get_short(&self) -> Option<char>
pub fn get_long(&self) -> Option<&str>
pub fn get_metavar(&self) -> Option<&str>
pub fn get_help(&self) -> Option<&str>
pub fn get_env(&self) -> Option<&str>
pub fn get_default(&self) -> Option<&OsString>
pub fn get_group(&self) -> Option<&str>
pub fn is_value(&self) -> bool
pub fn get_repeat(&self) -> Repeat
pub fn get_on_value(&self) -> Option<&OnValueFn<'a, Ctx>>
pub fn get_on_flag(&self) -> Option<&OnFlagFn<'a, Ctx>>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more