pub struct SpecFlag {Show 20 fields
pub name: 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 short: Vec<char>,
pub long: Vec<String>,
pub required: bool,
pub deprecated: Option<String>,
pub var: bool,
pub var_min: Option<usize>,
pub var_max: Option<usize>,
pub hide: bool,
pub global: bool,
pub count: bool,
pub arg: Option<SpecArg>,
pub default: Vec<String>,
pub negate: Option<String>,
pub env: Option<String>,
}Expand description
A CLI flag/option specification.
Flags are optional arguments that start with - (short) or -- (long).
They can be boolean switches or accept values.
§Example
use usage::SpecFlag;
let flag = SpecFlag::builder()
.short('v')
.long("verbose")
.help("Enable verbose output")
.build();Fields§
§name: StringInternal name for the flag (derived from long/short if not set)
usage: StringGenerated usage string (e.g., “-v, –verbose”)
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)
short: Vec<char>Short flag characters (e.g., ‘v’ for -v)
long: Vec<String>Long flag names (e.g., “verbose” for –verbose)
required: boolWhether this flag must be provided
deprecated: Option<String>Deprecation message if this flag is deprecated
var: boolWhether this flag can be specified multiple times
var_min: Option<usize>Minimum number of times this flag must appear (for var flags)
var_max: Option<usize>Maximum number of times this flag can appear (for var flags)
hide: boolWhether to hide this flag from help output
global: boolWhether this flag is available to all subcommands
count: boolWhether this is a count flag (e.g., -vvv counts as 3)
arg: Option<SpecArg>Argument specification if this flag takes a value
default: Vec<String>Default value(s) if the flag is not provided
negate: Option<String>Negation prefix (e.g., “no-” for –no-verbose)
env: Option<String>Environment variable that can set this flag’s value
Implementations§
Trait Implementations§
impl Eq for SpecFlag
Auto Trait Implementations§
impl Freeze for SpecFlag
impl RefUnwindSafe for SpecFlag
impl Send for SpecFlag
impl Sync for SpecFlag
impl Unpin for SpecFlag
impl UnwindSafe for SpecFlag
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