cute

Struct Cute

Source
pub struct Cute<S: State> { /* private fields */ }
Expand description

The main parser struct that holds options and their values.

§Type Parameters

  • S - The state type that implements the State trait

Implementations§

Source§

impl<S: State> Cute<S>

Source

pub fn new() -> Self

Creates a new Cute instance with empty options and values.

Source

pub fn add(&mut self, arg: impl StateOpt<S = S> + 'static) -> &mut Self

Adds a new option to the parser.

§Arguments
  • arg - The option to add, must implement StateOpt
Source

pub fn get(&self, s: S) -> Option<&dyn StateOpt<S = S>>

Gets an option by its state.

§Arguments
  • s - The state to search for
§Returns

Option containing a reference to the option if found

Source

pub fn has(&self, s: S) -> bool

Source

pub fn value<V: ValueParser>(&self, s: S) -> Result<V::Out<'_>, V::Error>

Gets a parsed value for a given state.

§Type Parameters
  • V - The value parser type
§Arguments
  • s - The state to get the value for
§Returns

Result containing the parsed value or an error

Source

pub fn pop_raw_value(&mut self, s: S) -> Result<String, Error>

Source

pub fn raw_values(&self, s: S) -> Result<&[String], Error>

Source

pub fn parse<I: Iterator>(&mut self, iter: I) -> Result<Vec<String>, Error>
where I::Item: ToString,

Parses command-line arguments from an iterator.

§Type Parameters
  • I - The iterator type
§Arguments
  • iter - The iterator of arguments to parse
§Returns

Result containing unprocessed arguments or an error

Source

pub fn parse_env(&mut self) -> Result<Vec<String>, Error>

Parses arguments from the environment.

§Returns

Result containing unprocessed arguments or an error

Trait Implementations§

Source§

impl<S: Default + State> Default for Cute<S>

Source§

fn default() -> Cute<S>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Cute<S>

§

impl<S> !RefUnwindSafe for Cute<S>

§

impl<S> !Send for Cute<S>

§

impl<S> !Sync for Cute<S>

§

impl<S> Unpin for Cute<S>
where S: Unpin,

§

impl<S> !UnwindSafe for Cute<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.