Skip to main content

ArgInfo

Struct ArgInfo 

Source
#[non_exhaustive]
pub struct ArgInfo {
Show 18 fields pub id: &'static str, pub kind: ArgKind, pub short: Option<char>, pub long: Option<&'static str>, pub visible_short_aliases: &'static [char], pub short_aliases: &'static [char], pub visible_aliases: &'static [&'static str], pub aliases: &'static [&'static str], pub value_name: &'static str, pub help: &'static str, pub long_help: &'static str, pub possible_values: &'static [&'static str], pub env: Option<&'static str>, pub hidden: bool, pub required: bool, pub multiple: bool, pub last: bool, pub global: bool,
}
Expand description

The description of one argument.

Values are built with ArgInfo::new and the const builder methods, so that fields can be added without breaking existing code.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: &'static str

The name of the field, or help and version for the generated flags.

§kind: ArgKind

How the argument is given.

§short: Option<char>

The short name, without the leading -.

§long: Option<&'static str>

The long name, without the leading --.

§visible_short_aliases: &'static [char]

The short aliases listed in the help.

§short_aliases: &'static [char]

The short aliases hidden from the help.

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

The long aliases listed in the help.

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

The long aliases hidden from the help.

§value_name: &'static str

The name of the value, e.g. FILE. Empty for flags.

§help: &'static str

The short help. Empty when not set.

§long_help: &'static str

The long help. Empty when not set.

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

The accepted values, from possible_values or a ValueEnum. Empty when any value is accepted.

§env: Option<&'static str>

The environment variable the argument falls back to.

§hidden: bool

Whether the argument is hidden from the help.

§required: bool

Whether the argument must be given.

§multiple: bool

Whether the argument can be given several times, e.g. a Count flag or a field collecting repeated values. A repeatable positional argument takes every remaining positional argument.

§last: bool

Whether the positional argument is only filled after --.

§global: bool

Whether the option is global: also accepted after the subcommands of its command, and listed in their help and completions.

Implementations§

Source§

impl ArgInfo

Source

pub const fn new(id: &'static str, kind: ArgKind) -> Self

An argument named id, without names, help or values.

Source

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

Sets short.

Source

pub const fn long(self, long: &'static str) -> Self

Sets long.

Source

pub const fn visible_short_aliases(self, aliases: &'static [char]) -> Self

Source

pub const fn short_aliases(self, aliases: &'static [char]) -> Self

Source

pub const fn visible_aliases(self, aliases: &'static [&'static str]) -> Self

Source

pub const fn aliases(self, aliases: &'static [&'static str]) -> Self

Sets aliases.

Source

pub const fn value_name(self, value_name: &'static str) -> Self

Sets value_name.

Source

pub const fn help(self, help: &'static str) -> Self

Sets help.

Source

pub const fn long_help(self, long_help: &'static str) -> Self

Sets long_help.

Source

pub const fn possible_values(self, values: &'static [&'static str]) -> Self

Source

pub const fn env(self, env: &'static str) -> Self

Sets env.

Source

pub const fn hidden(self, hidden: bool) -> Self

Sets hidden.

Source

pub const fn required(self, required: bool) -> Self

Sets required.

Source

pub const fn multiple(self, multiple: bool) -> Self

Sets multiple.

Source

pub const fn last(self, last: bool) -> Self

Sets last.

Source

pub const fn global(self, global: bool) -> Self

Sets global.

Source

pub const fn takes_value(&self) -> bool

Whether the argument takes a value: options and positional arguments.

Source

pub const fn is_positional(&self) -> bool

Whether the argument is positional.

Source

pub const fn long_or_short_help(&self) -> &'static str

The long help, or the short help when there is no long help.

Trait Implementations§

Source§

impl Clone for ArgInfo

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 ArgInfo

Source§

impl Debug for ArgInfo

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for ArgInfo

Source§

impl PartialEq for ArgInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ArgInfo

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

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.