[][src]Struct gong::options::OptionSetEx

pub struct OptionSetEx<'a> {
    pub long: Vec<LongOption<'a>>,
    pub short: Vec<ShortOption>,
    pub mode: OptionsMode,
    pub allow_abbreviations: bool,
}

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: OptionsModeallow_abbreviations: bool

Implementations

impl<'a> OptionSetEx<'a>[src]

pub fn new(count_long: usize, count_short: usize) -> Self[src]

Create a new object. Takes estimations of the number of options to expect to be added (for efficient vector allocation).

pub fn as_fixed(&self) -> OptionSet<'_, 'a>[src]

Create an OptionSet referencing self’s vectors as slices.

pub fn set_mode(&mut self, mode: OptionsMode) -> &mut Self[src]

Set mode

pub fn set_allow_abbreviations(&mut self, allow: bool) -> &mut Self[src]

Enable/disable abbreviated matching

pub fn is_empty(&self) -> bool[src]

Checks if empty

pub fn add_long(&mut self, name: &'a str) -> &mut Self[src]

Add a long option

Panics (debug only) on invalid name.

pub fn add_short(&mut self, ch: char) -> &mut Self[src]

Add a short option

Panics (debug only) on invalid char choice.

pub fn add_long_data(&mut self, name: &'a str) -> &mut Self[src]

Add a long option that expects data

Panics (debug only) on invalid name.

pub fn add_short_data(&mut self, ch: char) -> &mut Self[src]

Add a short option that expects data

Panics (debug only) on invalid char choice.

pub fn add_existing_long(&mut self, long: LongOption<'a>) -> &mut Self[src]

Add an existing (ready-made) long option

pub fn add_existing_short(&mut self, short: ShortOption) -> &mut Self[src]

Add an existing (ready-made) short option

pub fn is_valid(&self) -> bool[src]

Checks validity of option set

Returns true if valid.

See also the validate method.

pub fn validate(&self) -> Result<(), Vec<OptionFlaw<'a>>>[src]

Checks validity of option set, returning details of any problems

pub fn process<T>(&self, args: &'a [T]) -> Analysis<'a> where
    T: AsRef<str>, 
[src]

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

impl<'a> Clone for OptionSetEx<'a>[src]

impl<'a> Debug for OptionSetEx<'a>[src]

impl<'a> Default for OptionSetEx<'a>[src]

impl<'a> Eq for OptionSetEx<'a>[src]

impl<'r, 'a: 'r> PartialEq<OptionSet<'r, 'a>> for OptionSetEx<'a>[src]

impl<'a> PartialEq<OptionSetEx<'a>> for OptionSetEx<'a>[src]

impl<'r, 'a: 'r> PartialEq<OptionSetEx<'a>> for OptionSet<'r, 'a>[src]

impl<'a> StructuralEq for OptionSetEx<'a>[src]

impl<'a> StructuralPartialEq for OptionSetEx<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for OptionSetEx<'a>[src]

impl<'a> Send for OptionSetEx<'a>[src]

impl<'a> Sync for OptionSetEx<'a>[src]

impl<'a> Unpin for OptionSetEx<'a>[src]

impl<'a> UnwindSafe for OptionSetEx<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.