pub struct FlagMeta<'a> { /* private fields */ }Expand description
What a flag knows about itself beyond how it parses.
Read it through the accessor methods. The fields are pub only because derived code builds
this struct with a literal in the adopter’s crate; they are hidden from the docs because how
they are laid out is not part of the API.
Implementations§
Source§impl<'a> FlagMeta<'a>
Read access to every field, wherever it is stored.
impl<'a> FlagMeta<'a>
Read access to every field, wherever it is stored.
Prefer these to the fields: a field can move between this struct and its cold extra
half as tables are tuned for size, as 6.11.1 moved thirty-odd of them, and a getter keeps
its name and type when that happens.
pub const fn flag(&self) -> &'a Flag<'a>
Sourcepub const fn builtin(&self) -> bool
pub const fn builtin(&self) -> bool
A parser-supplied public entry point materialized in an exported spec.
It belongs in flag listings and completions, but not in the command synopsis where the runtime’s implicit help and version flags have never appeared.
Sourcepub const fn value_name(&self) -> Option<&'a str>
pub const fn value_name(&self) -> Option<&'a str>
The placeholder for the flag’s value, such as n in --jobs <n>.
pub const fn env(&self) -> Option<&'a str>
pub const fn default(&self) -> &'a [&'a str]
Sourcepub const fn accepted_choices(&self) -> &'a [&'a str]
pub const fn accepted_choices(&self) -> &'a [&'a str]
Canonical choices plus aliases accepted by the value type.
pub const fn choices(&self) -> &'a [&'a str]
pub const fn ignore_case(&self) -> bool
Sourcepub const fn allow_unknown_choices(&self) -> bool
pub const fn allow_unknown_choices(&self) -> bool
Accept values outside choices while retaining the list for help and completion.
pub const fn required(&self) -> bool
Sourcepub const fn value_optional(&self) -> bool
pub const fn value_optional(&self) -> bool
Whether the flag’s value may be left off, as in --bump or --bump 5.
Help only, and deliberately: usage-lib’s parser refuses a bare --bump exactly as it
refuses a bare --port, so this changes no binding — it changes the brackets, [BUMP]
rather than <BUMP>, which is what a spec’s arg "[BUMP]" required=#false says. In
FlagMeta and not in Flag for that reason: a parse never reads it.
pub const fn hide(&self) -> bool
pub const fn hide_default_value(&self) -> bool
pub const fn hide_env(&self) -> bool
pub const fn hide_possible_values(&self) -> bool
pub const fn hide_short_help(&self) -> bool
pub const fn hide_long_help(&self) -> bool
Sourcepub const fn count(&self) -> bool
pub const fn count(&self) -> bool
Whether repetition is counted rather than collected, as in -vvv.
Sourcepub const fn complete(
&self,
) -> Option<fn(&CompleteCtx<'_>) -> Vec<Candidate<'static>>>
pub const fn complete( &self, ) -> Option<fn(&CompleteCtx<'_>) -> Vec<Candidate<'static>>>
What answers for this flag’s value when a shell asks.
The Rust counterpart of a spec’s run=: it is written into the emitted KDL as a command
that asks this binary, so a spec stays complete for every other consumer while the
binary answers itself.
Sourcepub const fn repeatable(&self) -> bool
pub const fn repeatable(&self) -> bool
Whether the flag may be given more than once. Distinct from
Flag::variadic, which is one occurrence taking several values.
Sourcepub const fn help_heading(&self) -> Option<&'a str>
pub const fn help_heading(&self) -> Option<&'a str>
Heading to list this flag under in help output. Presentational: it groups a long flag list into sections and changes nothing about parsing.
Sourcepub const fn display_order(&self) -> Option<u32>
pub const fn display_order(&self) -> Option<u32>
Explicit placement within its help section.
Short forms accepted by the parser but omitted from help and completion.
Long forms accepted by the parser but omitted from help and completion.
Sourcepub const fn admonitions(&self) -> &'a [AdmonitionMeta<'a>]
pub const fn admonitions(&self) -> &'a [AdmonitionMeta<'a>]
Notes and warnings shown after the extended help text.
Sourcepub const fn deprecated(&self) -> Option<&'a str>
pub const fn deprecated(&self) -> Option<&'a str>
Why this flag is deprecated, plus optional release milestones.
pub const fn deprecated_warn_at(&self) -> Option<&'a str>
pub const fn deprecated_remove_at(&self) -> Option<&'a str>
Sourcepub const fn value_names(&self) -> &'a [&'a str]
pub const fn value_names(&self) -> &'a [&'a str]
Ordered placeholders for one fixed-arity occurrence.
pub const fn env_fallback(&self) -> &'a [&'a str]
pub const fn deprecated_env(&self) -> &'a [&'a str]
Sourcepub const fn choice_aliases(&self) -> &'a [(&'a str, &'a str)]
pub const fn choice_aliases(&self) -> &'a [(&'a str, &'a str)]
Canonical-to-alias pairs used when emitting a lossless spec.
Sourcepub const fn choice_details(&self) -> &'a [ChoiceMeta<'a>]
pub const fn choice_details(&self) -> &'a [ChoiceMeta<'a>]
Per-canonical presentation metadata used when emitting a lossless spec.
Sourcepub const fn validate(&self) -> Option<&'a str>
pub const fn validate(&self) -> Option<&'a str>
Portable expr expression evaluated for each raw value.
Sourcepub const fn validate_error(&self) -> Option<&'a str>
pub const fn validate_error(&self) -> Option<&'a str>
Message reported when validation returns false.
pub const fn hide_env_values(&self) -> bool
Sourcepub const fn complete_type(&self) -> Option<&'a str>
pub const fn complete_type(&self) -> Option<&'a str>
A built-in completion class such as path or dir.
pub const fn var_min(&self) -> Option<u32>
pub const fn var_max(&self) -> Option<u32>
Sourcepub const fn value_var_min(&self) -> Option<u32>
pub const fn value_var_min(&self) -> Option<u32>
Bounds on values consumed by one occurrence, distinct from the flag-level occurrence bounds above.
pub const fn value_var_max(&self) -> Option<u32>
Sourcepub const fn conflicts(&self) -> &'a [&'a str]
pub const fn conflicts(&self) -> &'a [&'a str]
Flags that cannot be given alongside this one.
Where overrides resolves a collision by letting the last
flag win, this reports it: the combination has no meaning, so honouring one
side silently would hide a mistake.
Sourcepub const fn delimiter(&self) -> Option<char>
pub const fn delimiter(&self) -> Option<char>
The character one word is split on to make several values, as clap’s
value_delimiter does. Only ever set where several values can land.
Sourcepub const fn exclusive(&self) -> bool
pub const fn exclusive(&self) -> bool
Whether this flag must be given on its own.
The whole-command form of conflicts: everything the command
declares counts, positionals included.
Sourcepub const fn requires(&self) -> &'a [&'a str]
pub const fn requires(&self) -> &'a [&'a str]
Flags that must also be given when this one is.
The positive form of conflicts, and the mirror image of
required_if: the same rule written on the flag that
imposes it rather than on the flag it lands on.
Sourcepub const fn requires_if(&self) -> &'a [RequiresIf<'a>]
pub const fn requires_if(&self) -> &'a [RequiresIf<'a>]
Value-triggered requirements declared by this flag.
Sourcepub const fn default_if(&self) -> &'a [DefaultIf<'a>]
pub const fn default_if(&self) -> &'a [DefaultIf<'a>]
Defaults that apply when another flag is given.
Sourcepub const fn required_if(&self) -> &'a [&'a str]
pub const fn required_if(&self) -> &'a [&'a str]
Flags that make this one necessary.
Sourcepub const fn required_if_eq(&self) -> &'a [RequiredIfEq<'a>]
pub const fn required_if_eq(&self) -> &'a [RequiredIfEq<'a>]
Selector/value conditions, any one of which makes this required.
Sourcepub const fn required_if_eq_all(&self) -> &'a [RequiredIfEq<'a>]
pub const fn required_if_eq_all(&self) -> &'a [RequiredIfEq<'a>]
Selector/value conditions which must all match to make this required.
Sourcepub const fn required_unless(&self) -> &'a [&'a str]
pub const fn required_unless(&self) -> &'a [&'a str]
Flags that make this one unnecessary.
Sourcepub const fn required_unless_all(&self) -> &'a [&'a str]
pub const fn required_unless_all(&self) -> &'a [&'a str]
All selectors must be present to make this unnecessary.
Sourcepub const fn surface(&self) -> Option<&'a str>
pub const fn surface(&self) -> Option<&'a str>
Named audience or compatibility surface this flag belongs to.
Sourcepub const fn available_if(&self) -> &'a [&'a str]
pub const fn available_if(&self) -> &'a [&'a str]
Descriptive availability conditions; they do not affect parsing.