Struct Parameter

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

Description of a parameter to be added to the Command.

The lifetime parameter 'a refers to the lifetime of the strings used for parameter names, aliases and help text.

Implementations§

Source§

impl<'a> Parameter<'a>

Source

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

Construct a default (blank) parameter with the given name.

Source

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

Mark the parameter as hidden. Hidden parameters will match within the parser, but are not listed during completion.

Source

pub fn priority(self, priority: i32) -> Self

Give the parameter a priority. This is used when sorting out conflicts during matching and completion.

The priority of a Parameter defaults to PRIORITY_PARAMETER except for when the kind is ParameterKind::Flag in which case, the default will be PRIORITY_DEFAULT.

This is not commonly needed.

Source

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

Establish whether or not this parameter is repeatable. Repeated parameters produce a vector of values and can be given multiple times within a single command invocation.

Source

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

Add an alias that this parameter can use.

Aliases are currently only valid for parameters of kind ParameterKind::Named.

Source

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

Supply the help text for the parameter.

Source

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

Establish whether or not this parameter is required.

Source

pub fn kind(self, kind: ParameterKind) -> Self

Set which type of ParameterNode is supposed to be created to represent this parameter.

Auto Trait Implementations§

§

impl<'a> Freeze for Parameter<'a>

§

impl<'a> RefUnwindSafe for Parameter<'a>

§

impl<'a> Send for Parameter<'a>

§

impl<'a> Sync for Parameter<'a>

§

impl<'a> Unpin for Parameter<'a>

§

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