Struct gong::options::OptionSetEx
source · 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 Vec
s 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: bool
Implementations§
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 is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks validity of option set
Returns true
if valid. Outputs details of problems found to stderr
.
sourcepub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>where
T: AsRef<str>,
pub fn process<T>(&self, args: &'a [T]) -> Analysis<'a>where
T: AsRef<str>,
Analyses provided program arguments.
This is the same as calling the process
function directly.
Returns a result set describing the result of the analysis. This may include &str
references to strings provided in the args
and options
parameter data. 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