Skip to main content

Argument

Struct Argument 

Source
pub struct Argument {
    pub strings: &'static [&'static str],
    pub name: &'static str,
    pub action: Action,
    pub nargs: Nargs,
    pub ty: Ty,
    pub group: Option<usize>,
    pub required: bool,
}
Expand description

An argument (add_argument).

Fields§

§strings: &'static [&'static str]

The option strings, in the order they are declared; empty for a positional argument.

§name: &'static str

The name of a positional argument in the messages (its metavar, or dest).

§action: Action

What it does.

§nargs: Nargs

How many values it takes.

§ty: Ty

The type of its values.

§group: Option<usize>

Its mutually exclusive group, if any.

§required: bool

Whether it is required.

Implementations§

Source§

impl Argument

Source

pub const fn help() -> Self

-h/--help.

Source

pub const fn version(strings: &'static [&'static str]) -> Self

action="version".

Source

pub const fn flag(strings: &'static [&'static str]) -> Self

action="store_true" (or store_false).

Source

pub const fn count(strings: &'static [&'static str]) -> Self

action="count".

Source

pub const fn option(strings: &'static [&'static str]) -> Self

An option with one value.

Source

pub const fn append(strings: &'static [&'static str]) -> Self

action="append": an option with one value, which may be given more than once.

Source

pub const fn positional(name: &'static str) -> Self

A positional argument with one value, named name in the messages.

Source

pub const fn nargs(self, nargs: Nargs) -> Self

nargs=; a positional argument is required unless it takes "?" or "*".

Source

pub const fn ty(self, ty: Ty) -> Self

type=.

Source

pub const fn group(self, group: usize) -> Self

The mutually exclusive group group.

Source

pub const fn required(self) -> Self

required=True.

Source

pub fn key(&self) -> &'static str

The key of the argument in Parsed: its first long option string, or its first option string, or the name of a positional argument.

Source

pub fn display(&self) -> String

_get_action_name: the option strings joined with /, or the name of a positional argument.

Trait Implementations§

Source§

impl Clone for Argument

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Argument

Source§

impl Debug for Argument

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Argument

§

impl Freeze for Argument
where &'static [&'static str]: Freeze, &'static str: Freeze,

§

impl Move for Argument

§

impl RefUnwindSafe for Argument

§

impl Send for Argument
where &'static [&'static str]: Send, &'static str: Send,

§

impl Sync for Argument

§

impl Unpin for Argument
where &'static [&'static str]: Unpin, &'static str: Unpin,

§

impl UnsafeUnpin for Argument
where &'static [&'static str]: UnsafeUnpin, &'static str: UnsafeUnpin,

§

impl UnwindSafe for Argument
where &'static [&'static str]: UnwindSafe, &'static str: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.