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.
type | action | ignore name | styles | index | alias | default value | creator | infer type |
---|---|---|---|---|---|---|---|---|
bool | Action::Set | false | Style::Combined Style::Boolean | no | true | false | b | bool |
i32 | Action::App | false | Style::Argument | no | true | None | None | None |
i64 | Action::App | false | Style::Argument | no | true | None | i | i64 |
u32 | Action::App | false | Style::Argument | no | true | None | None | None |
u64 | Action::App | false | Style::Argument | no | true | None | u | u64 |
f32 | Action::App | false | Style::Argument | no | true | None | None | None |
f64 | Action::App | false | Style::Argument | no | true | None | f | f64 |
usize | Action::App | false | Style::Argument | no | true | None | None | None |
isize | Action::App | false | Style::Argument | no | true | None | None | None |
String | Action::App | false | Style::Argument | no | true | None | s | String |
OsString | Action::App | false | Style::Argument | no | true | None | r | OsString |
Cmd | Action::Set | false | Style::Cmd | Forward(1) | true | false | c | Cmd |
Pos | Action::App | true | Style::Pos | yes | false | None | p | Pos |
Main | Action::Null | true | Style::Main | AnyWhere | false | None | m | Main |
Stdin | Action::Set | true | Style::Pos | AnyWhere | true | None | None | None |
For the value parser support, see RawValParser
.
Implementations§
source§impl AOpt
impl AOpt
pub fn new(name: AStr, type_id: TypeId, accessor: ValAccessor) -> Self
sourcepub fn with_ignore_name(self, ignore_name: bool) -> Self
pub fn with_ignore_name(self, ignore_name: bool) -> Self
If the option will matching the name.
sourcepub fn with_ignore_alias(self, ignore_alias: bool) -> Self
pub fn with_ignore_alias(self, ignore_alias: bool) -> Self
If the option will matching the alias.
sourcepub fn with_ignore_index(self, ignore_index: bool) -> Self
pub fn with_ignore_index(self, ignore_index: bool) -> Self
If the option will matching the alias.
sourcepub fn with_action(self, action: Action) -> Self
pub fn with_action(self, action: Action) -> Self
Set the value action of option.
sourcepub fn with_opt_help(self, help: Help) -> Self
pub fn with_opt_help(self, help: Help) -> Self
Set the help of option.
sourcepub fn with_style(self, styles: Vec<Style>) -> Self
pub fn with_style(self, styles: Vec<Style>) -> Self
Set the Style
of option.
sourcepub fn with_force(self, force: bool) -> Self
pub fn with_force(self, force: bool) -> Self
If the option is force required.
sourcepub fn with_alias(self, alias: Option<Vec<AStr>>) -> Self
pub fn with_alias(self, alias: Option<Vec<AStr>>) -> Self
Set the alias of option.
sourcepub fn with_accessor(self, value: ValAccessor) -> Self
pub fn with_accessor(self, value: ValAccessor) -> Self
Set the value accessor of option, it will used by Policy
;
source§impl AOpt
impl AOpt
pub fn set_name(&mut self, name: AStr) -> &mut Self
pub fn set_type(&mut self, type: TypeId) -> &mut Self
pub fn set_value(&mut self, value: ValAccessor) -> &mut Self
pub fn set_hint(&mut self, hint: AStr) -> &mut Self
pub fn set_help(&mut self, help: AStr) -> &mut Self
pub fn set_action(&mut self, action: Action) -> &mut Self
pub fn set_style(&mut self, styles: Vec<Style>) -> &mut Self
pub fn set_index(&mut self, index: Option<Index>) -> &mut Self
pub fn set_force(&mut self, force: bool) -> &mut Self
pub fn add_alias(&mut self, name: AStr) -> &mut Self
pub fn rem_alias(&mut self, name: &AStr) -> &mut Self
Trait Implementations§
source§impl Opt for AOpt
impl Opt for AOpt
fn reset(&mut self)
fn uid(&self) -> Uid
fn valid(&self) -> bool
fn accessor(&self) -> &ValAccessor
fn accessor_mut(&mut self) -> &mut ValAccessor
fn ignore_alias(&self) -> bool
fn ignore_name(&self) -> bool
fn ignore_index(&self) -> bool
fn set_uid(&mut self, uid: Uid)
fn set_matched(&mut self, matched: bool)
fn mat_style(&self, style: Style) -> bool
fn mat_force(&self, force: bool) -> bool
fn mat_name(&self, name: Option<&AStr>) -> bool
fn mat_alias(&self, name: &AStr) -> bool
fn mat_index(&self, index: Option<(usize, usize)>) -> bool
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> 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
source§impl<O> OptValueExt for Owhere
O: Opt,
impl<O> OptValueExt for Owhere
O: Opt,
source§fn filter<T>(&mut self, f: impl FnMut(&T) -> bool) -> Result<Vec<T>, Error>where
T: ErasedTy,
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.