Struct commands::parser::Parameter
[−]
[src]
pub struct Parameter<'a> { // some fields omitted }
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.
Methods
impl<'a> Parameter<'a>
fn new(name: &'a str) -> Self
Construct a default (blank) parameter with the given name
.
fn hidden(self, hidden: bool) -> Self
Mark the parameter as hidden. Hidden parameters will match within the parser, but are not listed during completion.
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.
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.
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
.
fn help(self, help_text: &'a str) -> Self
Supply the help text for the parameter.
fn required(self, required: bool) -> Self
Establish whether or not this parameter is required.
fn kind(self, kind: ParameterKind) -> Self
Set which type of ParameterNode
is supposed to be created
to represent this parameter.