#[non_exhaustive]pub struct SpecArg {Show 39 fields
pub name: String,
pub value_names: Vec<String>,
pub usage: String,
pub help: Option<String>,
pub help_long: Option<String>,
pub help_md: Option<String>,
pub help_first_line: Option<String>,
pub required: bool,
pub double_dash: SpecDoubleDashChoices,
pub var: bool,
pub var_min: Option<usize>,
pub var_max: Option<usize>,
pub delimiter: Option<char>,
pub allow_negative_numbers: bool,
pub value_terminator: Option<String>,
pub hide: bool,
pub hide_default_value: bool,
pub hide_env: bool,
pub hide_env_values: bool,
pub hide_possible_values: bool,
pub hide_short_help: bool,
pub hide_long_help: bool,
pub conflicts: Vec<String>,
pub requires: Vec<String>,
pub required_if: Vec<String>,
pub required_if_eq: Vec<SpecRequiredIfEq>,
pub required_if_eq_all: Vec<SpecRequiredIfEq>,
pub required_unless: Vec<String>,
pub required_unless_all: Vec<String>,
pub default: Vec<String>,
pub choices: Option<SpecChoices>,
pub validate: Option<String>,
pub validate_error: Option<String>,
pub effect: Option<SpecCommandEffect>,
pub env: Option<String>,
pub env_fallback: Vec<String>,
pub deprecated_env: Vec<String>,
pub help_heading: Option<String>,
pub display_order: Option<usize>,
}Expand description
A positional argument specification.
Arguments are positional values passed to a command without a flag prefix. They can be required or optional, and can accept multiple values (variadic).
§Example
use usage::SpecArg;
let arg = SpecArg::builder()
.name("file")
.required(true)
.help("Input file to process")
.build();Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringName of the argument (used in help text)
value_names: Vec<String>Ordered placeholders for a fixed-arity value, such as START and END.
Empty means the argument’s name is the sole placeholder.
usage: StringGenerated usage string (e.g., “
help: Option<String>Short help text shown in command listings
help_long: Option<String>Extended help text shown with –help
help_md: Option<String>Markdown-formatted help text
help_first_line: Option<String>First line of help text (auto-generated)
required: boolWhether this argument must be provided
double_dash: SpecDoubleDashChoicesHow to handle the “–” separator
var: boolWhether this argument accepts multiple values
var_min: Option<usize>Minimum number of values for variadic arguments
var_max: Option<usize>Maximum number of values for variadic arguments
delimiter: Option<char>The character a single word is split on to produce several values.
--tags a,b,c as three values rather than one, which is clap’s
value_delimiter. Only meaningful where several values can land, so it goes with
SpecArg::var; declaring it anywhere else is refused rather than silently
dropping everything after the first separator.
allow_negative_numbers: boolAccept negative numeric tokens without accepting arbitrary dash-prefixed words.
value_terminator: Option<String>End this variadic argument when this token is seen, without binding it.
hide: boolWhether to hide this argument from help output
hide_default_value: boolHide the default annotation while keeping the default behavior.
hide_env: boolHide the environment annotation entirely.
hide_env_values: boolHide an environment value while retaining its variable name.
hide_possible_values: boolHide possible values from help without changing validation.
hide_short_help: boolHide this argument only from short help.
hide_long_help: boolHide this argument only from long help.
conflicts: Vec<String>Arguments and flags that cannot be given alongside this positional.
A bare selector names another positional by name; flag selectors keep their
--long or -s spelling.
requires: Vec<String>Arguments that must also be present when this positional is present.
required_if: Vec<String>Presence conditions, any one of which makes this positional required.
required_if_eq: Vec<SpecRequiredIfEq>Value conditions, any one of which makes this positional required.
required_if_eq_all: Vec<SpecRequiredIfEq>Value conditions which must all match to make this positional required.
required_unless: Vec<String>Any present selector waives this positional’s requirement.
required_unless_all: Vec<String>Only the presence of every selector waives this positional’s requirement.
default: Vec<String>Default value(s) if the argument is not provided
choices: Option<SpecChoices>Valid choices for this argument
validate: Option<String>A portable expr expression that must return true for each raw value.
validate_error: Option<String>Message reported when SpecArg::validate returns false.
effect: Option<SpecCommandEffect>Raises the effect of the command when this argument is supplied.
See crate::spec::effect::SpecCommandEffect; never lowers it.
env: Option<String>Environment variable that can provide this argument’s value
env_fallback: Vec<String>Additional environment variables, consulted in declaration order.
deprecated_env: Vec<String>Deprecated environment aliases, consulted after ordinary fallbacks.
help_heading: Option<String>Heading this argument is listed under in help output. Presentational only, like the flag field of the same name.
display_order: Option<usize>Explicit placement within its help section.
Implementations§
Trait Implementations§
impl Eq for SpecArg
Auto Trait Implementations§
impl Freeze for SpecArg
impl RefUnwindSafe for SpecArg
impl Send for SpecArg
impl Sync for SpecArg
impl Unpin for SpecArg
impl UnsafeUnpin for SpecArg
impl UnwindSafe for SpecArg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more