Struct ArgWrap

Source
pub struct ArgWrap<'a> { /* private fields */ }
Expand description

Wrapper of Arg to deserialize with DeserializeSeed.

Methods from Deref<Target = Arg<'a>>§

Source

pub fn is_set(&self, s: ArgSettings) -> bool

Check if the ArgSettings variant is currently set on the argument.

Source

pub fn get_id(&self) -> &'help str

Get the name of the argument

Source

pub fn get_name(&self) -> &'help str

Deprecated, replaced with Arg::get_id

Source

pub fn get_help(&self) -> Option<&'help str>

Get the help specified for this argument, if any

Source

pub fn get_long_help(&self) -> Option<&'help str>

Get the long help specified for this argument, if any

§Examples
let arg = Arg::new("foo").long_help("long help");
assert_eq!(Some("long help"), arg.get_long_help());
Source

pub fn get_help_heading(&self) -> Option<&'help str>

Get the help heading specified for this argument, if any

Source

pub fn get_short(&self) -> Option<char>

Get the short option name for this argument, if any

Source

pub fn get_visible_short_aliases(&self) -> Option<Vec<char>>

Get visible short aliases for this argument, if any

Source

pub fn get_all_short_aliases(&self) -> Option<Vec<char>>

Get all short aliases for this argument, if any, both visible and hidden.

Source

pub fn get_short_and_visible_aliases(&self) -> Option<Vec<char>>

Get the short option name and its visible aliases, if any

Source

pub fn get_long(&self) -> Option<&'help str>

Get the long option name for this argument, if any

Source

pub fn get_visible_aliases(&self) -> Option<Vec<&'help str>>

Get visible aliases for this argument, if any

Source

pub fn get_all_aliases(&self) -> Option<Vec<&'help str>>

Get all aliases for this argument, if any, both visible and hidden.

Source

pub fn get_long_and_visible_aliases(&self) -> Option<Vec<&'help str>>

Get the long option name and its visible aliases, if any

Source

pub fn get_possible_values(&self) -> Option<&[PossibleValue<'help>]>

Deprecated, replaced with [Arg::get_value_parser().possible_values()]

Source

pub fn get_value_names(&self) -> Option<&[&'help str]>

Get the names of values for this argument.

Source

pub fn get_num_vals(&self) -> Option<usize>

Get the number of values for this argument.

Source

pub fn get_value_delimiter(&self) -> Option<char>

Get the delimiter between multiple values

Source

pub fn get_index(&self) -> Option<usize>

Get the index of this argument, if any

Source

pub fn get_value_hint(&self) -> ValueHint

Get the value hint of this argument

Source

pub fn get_global(&self) -> bool

Deprecated, replaced with Arg::is_global_set

Source

pub fn get_env(&self) -> Option<&OsStr>

Get the environment variable name specified for this argument, if any

§Examples
let arg = Arg::new("foo").env("ENVIRONMENT");
assert_eq!(Some(OsStr::new("ENVIRONMENT")), arg.get_env());
Source

pub fn get_default_values(&self) -> &[&OsStr]

Get the default values specified for this argument, if any

§Examples
let arg = Arg::new("foo").default_value("default value");
assert_eq!(&["default value"], arg.get_default_values());
Source

pub fn is_positional(&self) -> bool

Checks whether this argument is a positional or not.

§Examples
let arg = Arg::new("foo");
assert_eq!(true, arg.is_positional());

let arg = Arg::new("foo").long("foo");
assert_eq!(false, arg.is_positional());
Source

pub fn is_required_set(&self) -> bool

Reports whether Arg::required is set

Source

pub fn is_multiple_values_set(&self) -> bool

Report whether Arg::multiple_values is set

Source

pub fn is_multiple_occurrences_set(&self) -> bool

Source

pub fn is_takes_value_set(&self) -> bool

Report whether Arg::is_takes_value_set is set

Source

pub fn is_allow_hyphen_values_set(&self) -> bool

Report whether Arg::allow_hyphen_values is set

Source

pub fn is_forbid_empty_values_set(&self) -> bool

Deprecated, replaced with Arg::get_value_parser()

Source

pub fn is_allow_invalid_utf8_set(&self) -> bool

Deprecated, replaced with [Arg::get_value_parser()

Source

pub fn get_action(&self) -> &ArgAction

Behavior when parsing the argument

Source

pub fn get_value_parser(&self) -> &ValueParser

Configured parser for argument values

§Example
let cmd = clap::Command::new("raw")
    .arg(
        clap::Arg::new("port")
            .value_parser(clap::value_parser!(usize))
    );
let value_parser = cmd.get_arguments()
    .find(|a| a.get_id() == "port").unwrap()
    .get_value_parser();
println!("{:?}", value_parser);
Source

pub fn is_global_set(&self) -> bool

Report whether Arg::global is set

Source

pub fn is_next_line_help_set(&self) -> bool

Report whether Arg::next_line_help is set

Source

pub fn is_hide_set(&self) -> bool

Report whether Arg::hide is set

Source

pub fn is_hide_default_value_set(&self) -> bool

Report whether Arg::hide_default_value is set

Source

pub fn is_hide_possible_values_set(&self) -> bool

Report whether Arg::hide_possible_values is set

Source

pub fn is_hide_env_set(&self) -> bool

Report whether Arg::hide_env is set

Source

pub fn is_hide_env_values_set(&self) -> bool

Report whether Arg::hide_env_values is set

Source

pub fn is_hide_short_help_set(&self) -> bool

Report whether Arg::hide_short_help is set

Source

pub fn is_hide_long_help_set(&self) -> bool

Report whether Arg::hide_long_help is set

Source

pub fn is_use_value_delimiter_set(&self) -> bool

Report whether Arg::use_value_delimiter is set

Source

pub fn is_require_value_delimiter_set(&self) -> bool

Report whether Arg::require_value_delimiter is set

Source

pub fn is_require_equals_set(&self) -> bool

Report whether Arg::require_equals is set

Source

pub fn is_exclusive_set(&self) -> bool

Reports whether Arg::exclusive is set

Source

pub fn is_last_set(&self) -> bool

Reports whether Arg::last is set

Source

pub fn is_ignore_case_set(&self) -> bool

Reports whether Arg::ignore_case is set

Trait Implementations§

Source§

impl<'a> Clone for ArgWrap<'a>

Source§

fn clone(&self) -> ArgWrap<'a>

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<'a> Debug for ArgWrap<'a>

Source§

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

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

impl<'a> Deref for ArgWrap<'a>

Source§

type Target = Arg<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de> DeserializeSeed<'de> for ArgWrap<'de>

Source§

type Value = ArgWrap<'de>

The type produced by using this seed.
Source§

fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where D: Deserializer<'de>,

Equivalent to the more common Deserialize::deserialize method, except with some initial piece of data (the seed) passed in.
Source§

impl<'a> From<Arg<'a>> for ArgWrap<'a>

Source§

fn from(arg: Arg<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<ArgWrap<'a>> for Arg<'a>

Source§

fn from(arg: ArgWrap<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for ArgWrap<'a>

§

impl<'a> !RefUnwindSafe for ArgWrap<'a>

§

impl<'a> Send for ArgWrap<'a>

§

impl<'a> Sync for ArgWrap<'a>

§

impl<'a> Unpin for ArgWrap<'a>

§

impl<'a> !UnwindSafe for ArgWrap<'a>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.