Struct aopt::opt::AOpt

source ·
pub struct AOpt { /* private fields */ }
Expand description

A multiple features option type.

Some types support by default, they all implement Infer. When create the option with creator using add_opt, the Creator will retrieve other informations from the infer type list on the table. When create the option from type using infer, the Creator will retrieve other informations from given type.

typeactionignore namestylesindexaliasdefault valuecreatorinfer type
boolAction::SetfalseStyle::Combined Style::Booleannotruefalsebbool
i32Action::AppfalseStyle::ArgumentnotrueNoneNoneNone
i64Action::AppfalseStyle::ArgumentnotrueNoneii64
u32Action::AppfalseStyle::ArgumentnotrueNoneNoneNone
u64Action::AppfalseStyle::ArgumentnotrueNoneuu64
f32Action::AppfalseStyle::ArgumentnotrueNoneNoneNone
f64Action::AppfalseStyle::ArgumentnotrueNoneff64
usizeAction::AppfalseStyle::ArgumentnotrueNoneNoneNone
isizeAction::AppfalseStyle::ArgumentnotrueNoneNoneNone
StringAction::AppfalseStyle::ArgumentnotrueNonesString
OsStringAction::AppfalseStyle::ArgumentnotrueNonerOsString
CmdAction::SetfalseStyle::CmdForward(1)truefalsecCmd
PosAction::ApptrueStyle::PosyesfalseNonepPos
MainAction::NulltrueStyle::MainAnyWherefalseNonemMain
StdinAction::SettrueStyle::PosAnyWheretrueNoneNoneNone

For the value parser support, see RawValParser.

Implementations§

source§

impl AOpt

source

pub fn new(name: AStr, type_id: TypeId, accessor: ValAccessor) -> Self

source

pub fn with_uid(self, uid: Uid) -> Self

Set the unique identifier of option.

source

pub fn with_name(self, name: AStr) -> Self

Set the name of option.

source

pub fn with_type(self, type: TypeId) -> Self

Set the type of option, see Ctor.

source

pub fn with_ignore_name(self, ignore_name: bool) -> Self

If the option will matching the name.

source

pub fn with_ignore_alias(self, ignore_alias: bool) -> Self

If the option will matching the alias.

source

pub fn with_ignore_index(self, ignore_index: bool) -> Self

If the option will matching the alias.

source

pub fn with_hint(self, hint: AStr) -> Self

Set the hint of option, such as --option.

source

pub fn with_help(self, help: AStr) -> Self

Set the help message of option.

source

pub fn with_action(self, action: Action) -> Self

Set the value action of option.

source

pub fn with_opt_help(self, help: Help) -> Self

Set the help of option.

source

pub fn with_style(self, styles: Vec<Style>) -> Self

Set the Style of option.

source

pub fn with_idx(self, index: Option<Index>) -> Self

Set the NOA index of option.

source

pub fn with_force(self, force: bool) -> Self

If the option is force required.

source

pub fn with_alias(self, alias: Option<Vec<AStr>>) -> Self

Set the alias of option.

source

pub fn with_accessor(self, value: ValAccessor) -> Self

Set the value accessor of option, it will used by Policy;

source§

impl AOpt

source

pub fn set_name(&mut self, name: AStr) -> &mut Self

source

pub fn set_type(&mut self, type: TypeId) -> &mut Self

source

pub fn set_value(&mut self, value: ValAccessor) -> &mut Self

source

pub fn set_hint(&mut self, hint: AStr) -> &mut Self

source

pub fn set_help(&mut self, help: AStr) -> &mut Self

source

pub fn set_action(&mut self, action: Action) -> &mut Self

source

pub fn set_style(&mut self, styles: Vec<Style>) -> &mut Self

source

pub fn set_index(&mut self, index: Option<Index>) -> &mut Self

source

pub fn set_force(&mut self, force: bool) -> &mut Self

source

pub fn add_alias(&mut self, name: AStr) -> &mut Self

source

pub fn rem_alias(&mut self, name: &AStr) -> &mut Self

Trait Implementations§

source§

impl Debug for AOpt

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Opt for AOpt

source§

fn reset(&mut self)

source§

fn uid(&self) -> Uid

source§

fn name(&self) -> &AStr

The name of option.
source§

fn type(&self) -> &TypeId

The type of option.
source§

fn hint(&self) -> &AStr

The help hint of option such as --flag.
source§

fn help(&self) -> &AStr

The help message of option.
source§

fn valid(&self) -> bool

source§

fn matched(&self) -> bool

If the option matched.
source§

fn force(&self) -> bool

If the option is force required.
source§

fn action(&self) -> &Action

The associaed action of option.
source§

fn index(&self) -> Option<&Index>

The index of option.
source§

fn alias(&self) -> Option<&Vec<AStr>>

The alias the option.
source§

fn accessor(&self) -> &ValAccessor

source§

fn accessor_mut(&mut self) -> &mut ValAccessor

source§

fn ignore_alias(&self) -> bool

source§

fn ignore_name(&self) -> bool

source§

fn ignore_index(&self) -> bool

source§

fn set_uid(&mut self, uid: Uid)

source§

fn set_matched(&mut self, matched: bool)

source§

fn mat_style(&self, style: Style) -> bool

source§

fn mat_force(&self, force: bool) -> bool

source§

fn mat_name(&self, name: Option<&AStr>) -> bool

source§

fn mat_alias(&self, name: &AStr) -> bool

source§

fn mat_index(&self, index: Option<(usize, usize)>) -> bool

source§

fn init(&mut self) -> Result<(), Error>

Auto Trait Implementations§

§

impl Freeze for AOpt

§

impl !RefUnwindSafe for AOpt

§

impl !Send for AOpt

§

impl !Sync for AOpt

§

impl Unpin for AOpt

§

impl !UnwindSafe for AOpt

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<O> OptValueExt for O
where O: Opt,

source§

fn filter<T>(&mut self, f: impl FnMut(&T) -> bool) -> Result<Vec<T>, Error>
where T: ErasedTy,

Filter the value from option values if f return true.

source§

fn val<T>(&self) -> Result<&T, Error>
where T: ErasedTy,

source§

fn val_mut<T>(&mut self) -> Result<&mut T, Error>
where T: ErasedTy,

source§

fn vals<T>(&self) -> Result<&Vec<T>, Error>
where T: ErasedTy,

source§

fn vals_mut<T>(&mut self) -> Result<&mut Vec<T>, Error>
where T: ErasedTy,

source§

fn entry<T>(&mut self) -> Entry<'_, Vec<T>>
where T: ErasedTy,

source§

fn rawval(&self) -> Result<&RawVal, Error>

source§

fn rawval_mut(&mut self) -> Result<&mut RawVal, Error>

source§

fn rawvals(&self) -> Result<&Vec<RawVal>, Error>

source§

fn rawvals_mut(&mut self) -> Result<&mut Vec<RawVal>, Error>

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> ErasedTy for T
where T: Any + 'static,