Skip to main content

FlagMeta

Struct FlagMeta 

Source
pub struct FlagMeta<'a> {
Show 24 fields pub flag: &'a Flag<'a>, pub builtin: bool, pub help: Option<&'a str>, pub long_help: Option<&'a str>, pub value_name: Option<&'a str>, pub env: Option<&'a str>, pub default: &'a [&'a str], pub accepted_choices: &'a [&'a str], pub choices: &'a [&'a str], pub ignore_case: bool, pub allow_unknown_choices: bool, pub required: bool, pub value_optional: bool, pub hide: bool, pub hide_default_value: bool, pub hide_env: bool, pub hide_possible_values: bool, pub hide_short_help: bool, pub hide_long_help: bool, pub count: bool, pub complete: Option<fn(&CompleteCtx<'_>) -> Vec<Candidate<'static>>>, pub repeatable: bool, pub help_heading: Option<&'a str>, pub extra: &'a FlagExtra<'a>,
}
Expand description

What a flag knows about itself beyond how it parses.

Fields§

§flag: &'a Flag<'a>§builtin: 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.

§help: Option<&'a str>

Short help, shown by -h.

§long_help: Option<&'a str>

Long help, shown by --help.

§value_name: Option<&'a str>

The placeholder for the flag’s value, such as n in --jobs <n>.

§env: Option<&'a str>§default: &'a [&'a str]§accepted_choices: &'a [&'a str]

Canonical choices plus aliases accepted by the value type.

§choices: &'a [&'a str]§ignore_case: bool§allow_unknown_choices: bool

Accept values outside choices while retaining the list for help and completion.

§required: bool§value_optional: 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.

§hide: bool§hide_default_value: bool§hide_env: bool§hide_possible_values: bool§hide_short_help: bool§hide_long_help: bool§count: bool

Whether repetition is counted rather than collected, as in -vvv.

§complete: 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.

§repeatable: bool

Whether the flag may be given more than once. Distinct from Flag::variadic, which is one occurrence taking several values.

§help_heading: 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.

§extra: &'a FlagExtra<'a>

Everything a flag rarely declares: relations to other flags, deprecation, validation, bounds, and spec-only metadata. Shared through NO_FLAG_EXTRA by every flag that declares none of it, so a table pays for these fields once rather than per flag.

Implementations§

Source§

impl FlagMeta<'_>

Source

pub const EMPTY: FlagMeta<'static>

Metadata for a flag with nothing declared, for struct update syntax.

Trait Implementations§

Source§

impl<'a> Clone for FlagMeta<'a>

Source§

fn clone(&self) -> FlagMeta<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for FlagMeta<'a>

Source§

impl<'a> Debug for FlagMeta<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FlagMeta<'a>

§

impl<'a> RefUnwindSafe for FlagMeta<'a>

§

impl<'a> Send for FlagMeta<'a>

§

impl<'a> Sync for FlagMeta<'a>

§

impl<'a> Unpin for FlagMeta<'a>

§

impl<'a> UnsafeUnpin for FlagMeta<'a>

§

impl<'a> UnwindSafe for FlagMeta<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.