Skip to main content

AOpt

Struct 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::SetfalseStyle::BooleanNonetrueNoneNoneStdin
StopAction::SetfalseStyle::BooleanNonetrueNoneNoneStop

For the value parser support, see RawValParser.

Implementations§

Source§

impl AOpt

Source

pub fn new(name: String, 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: impl Into<String>) -> 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: impl Into<String>) -> Self

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

Source

pub fn with_help(self, help: impl Into<String>) -> 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<String>>) -> 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: impl Into<String>) -> &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: impl Into<String>) -> &mut Self

Source

pub fn set_help(&mut self, help: impl Into<String>) -> &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: impl Into<String>) -> &mut Self

Source

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

Source

pub fn set_ignore_name(&mut self, ignore_name: bool) -> &mut Self

Source

pub fn set_ignore_alias(&mut self, ignore_alias: bool) -> &mut Self

Source

pub fn set_ignore_index(&mut self, ignore_index: bool) -> &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

The Uid of option.
Source§

fn name(&self) -> &str

The name of option.
Source§

fn type(&self) -> &TypeId

The type of option.
Source§

fn hint(&self) -> &str

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

fn help(&self) -> &str

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

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<&str>) -> bool

Source§

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

Source§

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

Source§

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

Source§

fn set_name(&mut self, name: impl Into<String>) -> &mut Self

Source§

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

Source§

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

Source§

fn set_hint(&mut self, hint: impl Into<String>) -> &mut Self

Source§

fn set_help(&mut self, help: impl Into<String>) -> &mut Self

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn add_alias(&mut self, name: impl Into<String>) -> &mut Self

Source§

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

Source§

fn set_ignore_name(&mut self, ignore_name: bool) -> &mut Self

Source§

fn set_ignore_alias(&mut self, ignore_alias: bool) -> &mut Self

Source§

fn set_ignore_index(&mut self, ignore_index: bool) -> &mut Self

Source§

impl TryFrom<OptConfig> for AOpt

Source§

type Error = Error

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

fn try_from(value: OptConfig) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for AOpt

§

impl !RefUnwindSafe for AOpt

§

impl Send for AOpt

§

impl Sync for AOpt

§

impl Unpin for AOpt

§

impl UnsafeUnpin 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<'a, C, T> DynamicCtorThenBuilderHelper<'a, C> for T
where C: Match<'a>,

Source§

fn into_ctor_then_builder<F, O1, R>( self, func: F, ) -> DynamicCtorThenBuilder<C, T, F>
where F: Fn(&mut C, &O1) -> Result<R, Error>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 take_val<T>(&mut self) -> Result<T, Error>
where T: ErasedTy,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> MayDebug for T