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 | false | Style::Boolean | None | true | None | None | Stdin |
Stop | Action::Set | false | Style::Boolean | None | true | None | None | Stop |
For the value parser support, see RawValParser.
Implementations§
Source§impl AOpt
impl AOpt
pub fn new(name: String, 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_hint(self, hint: impl Into<String>) -> Self
pub fn with_hint(self, hint: impl Into<String>) -> Self
Set the hint of option, such as --option.
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<String>>) -> Self
pub fn with_alias(self, alias: Option<Vec<String>>) -> 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: impl Into<String>) -> &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: impl Into<String>) -> &mut Self
pub fn set_help(&mut self, help: impl Into<String>) -> &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: impl Into<String>) -> &mut Self
pub fn rem_alias(&mut self, name: &str) -> &mut Self
pub fn set_ignore_name(&mut self, ignore_name: bool) -> &mut Self
pub fn set_ignore_alias(&mut self, ignore_alias: bool) -> &mut Self
pub fn set_ignore_index(&mut self, ignore_index: bool) -> &mut Self
Trait Implementations§
Source§impl Opt for AOpt
impl Opt for AOpt
fn reset(&mut self)
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<&str>) -> bool
fn mat_alias(&self, name: &str) -> bool
fn mat_index(&self, index: Option<(usize, usize)>) -> bool
fn init(&mut self) -> Result<(), Error>
fn set_name(&mut self, name: impl Into<String>) -> &mut Self
fn set_type(&mut self, type: TypeId) -> &mut Self
fn set_value(&mut self, value: ValAccessor) -> &mut Self
fn set_hint(&mut self, hint: impl Into<String>) -> &mut Self
fn set_help(&mut self, help: impl Into<String>) -> &mut Self
fn set_action(&mut self, action: Action) -> &mut Self
fn set_style(&mut self, styles: Vec<Style>) -> &mut Self
fn set_index(&mut self, index: Option<Index>) -> &mut Self
fn set_force(&mut self, force: bool) -> &mut Self
fn add_alias(&mut self, name: impl Into<String>) -> &mut Self
fn rem_alias(&mut self, name: &str) -> &mut Self
fn set_ignore_name(&mut self, ignore_name: bool) -> &mut Self
fn set_ignore_alias(&mut self, ignore_alias: bool) -> &mut Self
fn set_ignore_index(&mut self, ignore_index: bool) -> &mut Self
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> 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
Source§impl<'a, C, T> DynamicCtorThenBuilderHelper<'a, C> for Twhere
C: Match<'a>,
impl<'a, C, T> DynamicCtorThenBuilderHelper<'a, C> for Twhere
C: Match<'a>,
fn into_ctor_then_builder<F, O1, R>( self, func: F, ) -> DynamicCtorThenBuilder<C, T, F>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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.