pub struct AnpOption { /* private fields */ }Expand description
The AnpOption represents a single option.
§Examples
Create an option without argument: -v,--verbose
use anpcli::AnpOption;
let opt = AnpOption::builder().option("v").long_option("verbose").build();Create an option with single argument: -f <arg>.
use anpcli::AnpOption;
let opt = AnpOption::builder().option("f").has_arg(true).build();Create an option with multiple arguments: --file [<arg> ...]
use anpcli::AnpOption;
let opt = AnpOption::builder().long_option("file").has_args().optional_arg(true);
let another_opt = AnpOption::builder().long_option("file").number_of_args(3);Implementations§
Source§impl AnpOption
impl AnpOption
Sourcepub fn builder() -> OptionBuilder
pub fn builder() -> OptionBuilder
Create a OptionBuilder to config the option.
Sourcepub fn has_arg_name(&self) -> bool
pub fn has_arg_name(&self) -> bool
Check if the option has an argument name.
Sourcepub fn has_arg(&self) -> bool
pub fn has_arg(&self) -> bool
Check if the option accepts argument.
Also see Self::has_args
Sourcepub fn has_args(&self) -> bool
pub fn has_args(&self) -> bool
Check if the option accepts more than one arguments.
Also see Self::has_arg
Sourcepub fn has_long_opt(&self) -> bool
pub fn has_long_opt(&self) -> bool
Check if the option has a long option name.
Sourcepub fn has_no_value(&self) -> bool
pub fn has_no_value(&self) -> bool
Check if the option has a short option name.
Sourcepub fn has_optional_arg(&self) -> bool
pub fn has_optional_arg(&self) -> bool
Check whether the argument if optional
Sourcepub fn has_value_separator(&self) -> bool
pub fn has_value_separator(&self) -> bool
Check whether the option has value separator.
Sourcepub fn is_required(&self) -> bool
pub fn is_required(&self) -> bool
Check whether the option is required.
pub fn accepts_arg(&self) -> bool
pub fn requires_arg(&self) -> bool
pub fn add_value_for_processing(&mut self, value: &str) -> Result<(), OptionErr>
pub fn clear_values(&mut self)
pub fn get_arg_name(&self) -> Option<&String>
pub fn get_args(&self) -> &ArgCount
pub fn get_description(&self) -> Option<&String>
pub fn get_key(&self) -> &str
pub fn get_id(&self) -> char
pub fn get_long_opt(&self) -> Option<&String>
pub fn get_opt(&self) -> Option<&String>
pub fn get_value<T: FromStr>(&self) -> Option<Result<T, T::Err>>
pub fn get_value_at<T: FromStr>( &self, index: usize, ) -> Option<Result<T, T::Err>>
pub fn get_values<T: FromStr>(&self) -> Vec<Result<T, T::Err>>
pub fn get_value_separator(&self) -> Option<char>
pub fn set_arg_name(&mut self, arg_name: &str)
pub fn set_args(&mut self, num: usize)
pub fn set_description(&mut self, description: &str)
pub fn set_long_option(&mut self, long_option: &str)
pub fn set_optional_arg(&mut self, optional_arg: bool)
pub fn set_required(&mut self, required: bool)
pub fn set_value_separator(&mut self, value_sep: char)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AnpOption
impl RefUnwindSafe for AnpOption
impl Send for AnpOption
impl Sync for AnpOption
impl Unpin for AnpOption
impl UnwindSafe for AnpOption
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