pub struct OptionSetEx<'a> {
pub long: Vec<LongOption<'a>>,
pub short: Vec<ShortOption>,
pub mode: OptionsMode,
pub allow_abbreviations: bool,
}Expand description
Extendible option set
Used to supply the set of information about available options to match against
This is the “extendible” variant which uses Vecs to hold the option lists and thus is flexible
in allowing addition of options, and may re-allocate as necessary.
Fields§
§long: Vec<LongOption<'a>>§short: Vec<ShortOption>§mode: OptionsMode§allow_abbreviations: boolImplementations§
Source§impl<'a> OptionSetEx<'a>
impl<'a> OptionSetEx<'a>
Sourcepub fn new(count_long: usize, count_short: usize) -> Self
pub fn new(count_long: usize, count_short: usize) -> Self
Create a new object. Takes estimations of the number of options to expect to be added (for efficient vector allocation).
Sourcepub fn as_fixed(&self) -> OptionSet<'_, 'a>
pub fn as_fixed(&self) -> OptionSet<'_, 'a>
Create an OptionSet referencing self’s vectors as slices.
Sourcepub fn set_mode(&mut self, mode: OptionsMode) -> &mut Self
pub fn set_mode(&mut self, mode: OptionsMode) -> &mut Self
Set mode
Sourcepub fn set_allow_abbreviations(&mut self, allow: bool) -> &mut Self
pub fn set_allow_abbreviations(&mut self, allow: bool) -> &mut Self
Enable/disable abbreviated matching
Sourcepub fn add_long(&mut self, name: &'a str) -> &mut Self
pub fn add_long(&mut self, name: &'a str) -> &mut Self
Add a long option
Panics (debug only) on invalid name.
Sourcepub fn add_short(&mut self, ch: char) -> &mut Self
pub fn add_short(&mut self, ch: char) -> &mut Self
Add a short option
Panics (debug only) on invalid char choice.
Sourcepub fn add_long_data(&mut self, name: &'a str) -> &mut Self
pub fn add_long_data(&mut self, name: &'a str) -> &mut Self
Add a long option that expects data
Panics (debug only) on invalid name.
Sourcepub fn add_short_data(&mut self, ch: char) -> &mut Self
pub fn add_short_data(&mut self, ch: char) -> &mut Self
Add a short option that expects data
Panics (debug only) on invalid char choice.
Sourcepub fn add_existing_long(&mut self, long: LongOption<'a>) -> &mut Self
pub fn add_existing_long(&mut self, long: LongOption<'a>) -> &mut Self
Add an existing (ready-made) long option
Sourcepub fn add_existing_short(&mut self, short: ShortOption) -> &mut Self
pub fn add_existing_short(&mut self, short: ShortOption) -> &mut Self
Add an existing (ready-made) short option
Sourcepub fn validate(&self) -> Result<(), Vec<OptionFlaw<'a>>>
pub fn validate(&self) -> Result<(), Vec<OptionFlaw<'a>>>
Checks validity of option set, returning details of any problems
Sourcepub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>
pub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>
Analyses provided program arguments.
Returns a result set describing the result of the analysis. This may include &str
references to strings provided in the args parameter and in self. Take note of this with
respect to object lifetimes.
Expects self to be valid (see is_valid).
Trait Implementations§
Source§impl<'a> Clone for OptionSetEx<'a>
impl<'a> Clone for OptionSetEx<'a>
Source§fn clone(&self) -> OptionSetEx<'a>
fn clone(&self) -> OptionSetEx<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more