Argument

Struct Argument 

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

Stores the characteristics of the name command line argument.

Implementations§

Source§

impl<'a> Argument<'a>

Source

pub fn new(name: &'a str) -> Argument<'a>

Create a new Argument that keeps the necessary information for an argument.

Source

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

Set if the argument must be provided by user.

Source

pub fn requires(self, other_arg: &'a str) -> Self

Add other_arg as a required parameter when self is specified.

Source

pub fn forbids(self, args: Vec<&'a str>) -> Self

Add other_arg as a forbidden parameter when self is specified.

Source

pub fn takes_value(self, takes_value: bool) -> Self

If takes_value is true, then the user must provide a value for the argument, otherwise that argument is a flag.

Source

pub fn allow_multiple(self, allow_multiple: bool) -> Self

If allow_multiple is true, then the user can provide multiple values for the argument (e.g –arg val1 –arg val2). It sets the takes_value option to true, so the user must provides at least one value.

Source

pub fn default_value(self, default_value: &'a str) -> Self

Keep a default value which will be used if the user didn’t provide a value for the argument.

Source

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

Set the information that will be displayed for the argument when user passes --help flag.

Trait Implementations§

Source§

impl<'a> Clone for Argument<'a>

Source§

fn clone(&self) -> Argument<'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 Argument<'a>

Source§

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

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

impl<'a> PartialEq for Argument<'a>

Source§

fn eq(&self, other: &Argument<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for Argument<'a>

Source§

impl<'a> StructuralPartialEq for Argument<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Argument<'a>

§

impl<'a> RefUnwindSafe for Argument<'a>

§

impl<'a> Send for Argument<'a>

§

impl<'a> Sync for Argument<'a>

§

impl<'a> Unpin for Argument<'a>

§

impl<'a> UnwindSafe for Argument<'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<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.