pub struct Flag {Show 16 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 negatable: 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.
negatable: boolTrue if the tool documents this boolean flag’s negation inline —
GNU getopt_long’s --[no-]foo convention (git’s own --help
formatter renders every negatable boolean this way). long always
holds the base name ("foo", never "[no-]foo" or "no-foo"):
this field is what lets the negatability survive the parse without
smuggling [/] into the spelling users search and copy. See
mandible-extract/src/help_text/grammar.rs’s try_long for where
this is recognized, structurally, from the bracketed-prefix shape —
never from a tool name.
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.
Sourcepub fn spelling(&self) -> String
pub fn spelling(&self) -> String
A human-readable spelling for display and clipboard copy, e.g.
"-i, --interactive", "--output FILE", or "-S, --[no-]staged"
for a negatable boolean — the [no-] is reconstructed for display
from negatable, never stored in long itself (see the field’s
doc comment).