Skip to main content

CLOption

Struct CLOption 

Source
pub struct CLOption {
    pub short: Option<String>,
    pub long: Option<String>,
    pub description: String,
    pub takes_value: bool,
    pub value_name: String,
}
Expand description

A single named option (-v,--verbose, --count, etc.).

Uni’s launcher lets callers describe an option with a single comma-separated prefix string; we parse that same syntax here so port-over code reads the same.

Fields§

§short: Option<String>§long: Option<String>§description: String§takes_value: bool

true when the option consumes the next argument as its value, false for boolean flags.

§value_name: String

Placeholder shown in help output (e.g. <val>). Ignored for flags.

Implementations§

Source§

impl CLOption

Source

pub fn parse_flag(prefix: &str, description: impl Into<String>) -> Self

Parse a prefix like "-v,--verbose" into short/long tokens.

Returns a CLOption with takes_value == false (i.e. a flag). Use CLOption::parse_option to build a value-consuming option.

Panics if the prefix produces neither a short nor long alias (e.g. "" or "verbose" without a leading dash). Such an option can never be matched by the parser and would collide with other malformed options in the result map.

Source

pub fn parse_option(prefix: &str, description: impl Into<String>) -> Self

Like CLOption::parse_flag but the option consumes the next argument.

Source

pub fn canonical(&self) -> String

Canonical lookup key — the long name without dashes if present, otherwise the short name without dashes. Empty schemas are rejected at build time so one of the two is always populated.

Source

pub fn matches_long(&self, name: &str) -> bool

Source

pub fn matches_short(&self, name: &str) -> bool

Trait Implementations§

Source§

impl Clone for CLOption

Source§

fn clone(&self) -> CLOption

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CLOption

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.