pub struct Flag {Show 15 fields
pub short: Option<char>,
pub long: Option<String>,
pub value_name: Option<String>,
pub value_kind: ValueKind,
pub choices: Vec<Text>,
pub repeatable: bool,
pub required: bool,
pub hidden: bool,
pub deprecated: Option<Text>,
pub inherited: bool,
pub group: Option<String>,
pub description: Option<Text>,
pub default: Option<Text>,
pub env_var: Option<String>,
pub provenance: Provenance,
}Expand description
A single flag/option, e.g. -i, --interactive.
Fields§
§short: Option<char>Short spelling, e.g. Some('i') for -i.
long: Option<String>Long spelling, e.g. Some("interactive".into()) for --interactive.
value_name: Option<String>The value placeholder, e.g. "FILE" in --output FILE.
value_kind: ValueKindWhether this flag takes no value, a required value, or an optional one.
choices: Vec<Text>Enumerated choices, e.g. {json|yaml|table} for --format.
repeatable: boolTrue if this flag may be given more than once.
required: boolTrue if this flag is required.
True if this flag should be hidden by default.
deprecated: Option<Text>Some(reason) when this flag is deprecated.
inherited: boolTrue when this flag was declared on an ancestor node and propagated
down (cobra “persistent flag” / carapace persistentflags).
Rendered in a separate, dimmed group in the detail pane.
group: Option<String>Display grouping from the source, e.g. tar’s "Main operation mode".
description: Option<Text>The flag’s description.
default: Option<Text>The flag’s default value, if documented.
env_var: Option<String>An environment variable that also sets this flag, if documented.
provenance: ProvenanceWhich source(s) contributed this flag’s fields.
Implementations§
Source§impl Flag
impl Flag
Sourcepub fn long(name: impl Into<String>, provenance: Provenance) -> Flag
pub fn long(name: impl Into<String>, provenance: Provenance) -> Flag
A minimal flag with only a long spelling.
Sourcepub fn key(&self) -> Option<FlagKey>
pub fn key(&self) -> Option<FlagKey>
The canonical identity key used for cross-source matching and
addressing: prefer the long name, fall back to the short letter.
Returns None for a degenerate flag with neither (which cannot be
addressed and is only matched positionally during merge).
Sourcepub fn matches_key(&self, key: &FlagKey) -> bool
pub fn matches_key(&self, key: &FlagKey) -> bool
True if key addresses this flag, checking both spellings
regardless of which one is considered canonical.