Arg

Struct Arg 

Source
pub struct Arg {
    pub info: ArgInfo,
    pub validators: Vec<Box<dyn Validator>>,
    pub completers: Vec<Box<dyn Completer>>,
    pub prompters: Vec<Box<dyn Prompter>>,
}

Fields§

§info: ArgInfo§validators: Vec<Box<dyn Validator>>§completers: Vec<Box<dyn Completer>>§prompters: Vec<Box<dyn Prompter>>

Implementations§

Source§

impl Arg

Source

pub fn flag(long: impl Into<String>) -> Self

Create a boolean flag (no value)

Source

pub fn option(long: impl Into<String>, ty: ArgType) -> Self

Create an option with value

Source

pub fn positional(name: impl Into<String>, ty: ArgType) -> Self

Create a positional argument

Source

pub fn title(self, title: impl Into<String>) -> Self

Set the help/title for the argument

Source

pub fn description(self, description: impl Into<String>) -> Self

Set the description for the argument

Source

pub fn short(self, short: char) -> Self

Set the short flag (e.g., -v)

Source

pub fn aliases(self, aliases: Vec<String>) -> Self

Source

pub fn ty(self, ty: ArgType) -> Self

Source

pub fn required(self) -> Self

Mark as required

Source

pub fn default(self, value: impl Into<String>) -> Self

Set the default value

Source

pub fn multiple(self) -> Self

Set whether this argument accepts multiple values

Source

pub fn env(self, env_var: impl Into<String>) -> Self

Set environment variable to read default value from

Source

pub fn enums(self, options: Vec<(impl Into<String>, impl Into<String>)>) -> Self

Set enum options for this argument (label, value)

Source

pub fn validator(self, v: Box<dyn Validator + 'static>) -> Self

Set a validator (accepts closures or Validator trait implementations)

Source

pub fn completer(self, c: Box<dyn Completer + 'static>) -> Self

Set a completer (accepts closures or Completer trait implementations)

Source

pub fn prompter(self, p: Box<dyn Prompter + 'static>) -> Self

Set a prompter (accepts Prompter trait implementations)

Auto Trait Implementations§

§

impl Freeze for Arg

§

impl !RefUnwindSafe for Arg

§

impl !Send for Arg

§

impl !Sync for Arg

§

impl Unpin for Arg

§

impl !UnwindSafe for Arg

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.