pub struct CommandMeta<'a> {
pub cmd: &'a Command<'a>,
pub about: Option<&'a str>,
pub long_about: Option<&'a str>,
pub hide: bool,
pub args_override_self: bool,
pub flags: &'a [FlagMeta<'a>],
pub args: &'a [ArgMeta<'a>],
pub subcommands: &'a [&'a CommandMeta<'a>],
pub groups: &'a [GroupMeta<'a>],
pub flatten_groups: &'a [FlattenGroup<'a>],
pub extra: &'a CommandExtra<'a>,
}Expand description
What a command knows about itself beyond how it parses.
Fields§
§cmd: &'a Command<'a>The parse table this describes. Names, aliases, and structure come from here rather than being repeated.
about: Option<&'a str>§long_about: Option<&'a str>§hide: boolWhether the command is hidden from help and completions.
args_override_self: boolWhether later single-valued occurrences replace earlier ones.
flags: &'a [FlagMeta<'a>]Metadata for cmd.flags, in the same order.
args: &'a [ArgMeta<'a>]Metadata for cmd.args, in the same order.
subcommands: &'a [&'a CommandMeta<'a>]Metadata for cmd.subcommands, in the same order.
groups: &'a [GroupMeta<'a>]Sets of this command’s flags that relate to one another as a set.
Cold like everything else here: a group is checked once the last token has been read, by code the derive generates, and a successful parse never reads this.
flatten_groups: &'a [FlattenGroup<'a>]Which runs of Self::flags came from a flattened Args type.
Only Spec::to_kdl reads this, and only to write a flagset once instead of the
same flags under every command that flattens the struct. It changes nothing about
parsing: the flags are in flags either way, which is why this is a description of
where they came from rather than a table anything binds against.
extra: &'a CommandExtra<'a>Everything a command rarely declares: deprecation, hidden aliases, spec-only
metadata, help-page prose and layout settings. Shared through NO_COMMAND_EXTRA by
every command that declares none of it, which includes nearly every flattened Args
type, so a table pays for these fields once rather than per command.
Implementations§
Source§impl CommandMeta<'_>
impl CommandMeta<'_>
Sourcepub const EMPTY: CommandMeta<'static>
pub const EMPTY: CommandMeta<'static>
Metadata for a command with nothing declared, for struct update syntax.
Source§impl<'a> CommandMeta<'a>
Read access to every field, wherever it is stored.
impl<'a> CommandMeta<'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.
Sourcepub const fn cmd(&self) -> &'a Command<'a>
pub const fn cmd(&self) -> &'a Command<'a>
The parse table this describes. Names, aliases, and structure come from here rather than being repeated.
pub const fn about(&self) -> Option<&'a str>
pub const fn long_about(&self) -> Option<&'a str>
Sourcepub const fn args_override_self(&self) -> bool
pub const fn args_override_self(&self) -> bool
Whether later single-valued occurrences replace earlier ones.
Sourcepub const fn subcommands(&self) -> &'a [&'a CommandMeta<'a>]
pub const fn subcommands(&self) -> &'a [&'a CommandMeta<'a>]
Metadata for cmd.subcommands, in the same order.
Sourcepub const fn groups(&self) -> &'a [GroupMeta<'a>]
pub const fn groups(&self) -> &'a [GroupMeta<'a>]
Sets of this command’s flags that relate to one another as a set.
Cold like everything else here: a group is checked once the last token has been read, by code the derive generates, and a successful parse never reads this.
Sourcepub const fn flatten_groups(&self) -> &'a [FlattenGroup<'a>]
pub const fn flatten_groups(&self) -> &'a [FlattenGroup<'a>]
Which runs of Self::flags came from a flattened Args type.
Only Spec::to_kdl reads this, and only to write a flagset once instead of the
same flags under every command that flattens the struct. It changes nothing about
parsing: the flags are in flags either way, which is why this is a description of
where they came from rather than a table anything binds against.
Sourcepub const fn deprecated(&self) -> Option<&'a str>
pub const fn deprecated(&self) -> Option<&'a str>
Why this command 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>
Aliases that work but are not shown in help or completions. Everything in
cmd.aliases and not here is visible.
Sourcepub const fn help_heading(&self) -> Option<&'a str>
pub const fn help_heading(&self) -> Option<&'a str>
Help section this command appears under in its parent’s command list.
Sourcepub const fn surface(&self) -> Option<&'a str>
pub const fn surface(&self) -> Option<&'a str>
Named audience or compatibility surface this command 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.
Sourcepub const fn display_order(&self) -> Option<u32>
pub const fn display_order(&self) -> Option<u32>
Explicit placement within the parent’s command section.
Positions, bounds and widths in the metadata are u32 or u16 rather than usize,
which halves them in a table emitted for every command, flag and argument. A derive
saturates a larger declared value rather than wrapping it.
Sourcepub const fn effect(&self) -> Option<Effect>
pub const fn effect(&self) -> Option<Effect>
What running this does to the world, for a caller deciding whether to confirm first. clap cannot express this, which is why mise keeps a 330-entry table to bolt it on afterwards.
Sourcepub const fn mount(&self) -> Option<&'a str>
pub const fn mount(&self) -> Option<&'a str>
A command to run at parse time to discover further subcommands.
Only meaningful on a subcommand. The spec accepts mount inside a cmd
block and nowhere else, so setting this on the root is a mistake that
Spec::to_kdl catches in debug builds.
Sourcepub const fn restart_token(&self) -> Option<&'a str>
pub const fn restart_token(&self) -> Option<&'a str>
A token that starts a fresh invocation of this command, such as mise’s
:::.
Sourcepub const fn clause(&self) -> Option<&'a ClauseMeta<'a>>
pub const fn clause(&self) -> Option<&'a ClauseMeta<'a>>
Metadata for a repeatable positional clause.
Behind a reference for the reason Command::clause is.
Sourcepub const fn subcommand_required(&self) -> bool
pub const fn subcommand_required(&self) -> bool
Whether this command cannot be run on its own: naming it and stopping is an error, and one of its subcommands has to follow.
Cold metadata rather than a parse table, because it is not how a word binds —
the derive already refuses the invocation from the type, a bare T subcommand
field against an Option<T>. It is here so the emitted spec can say it, since
everything reading that spec — help, docs, completions — otherwise describes a
command as runnable when it is not.
Sourcepub const fn subcommand_help_heading(&self) -> Option<&'a str>
pub const fn subcommand_help_heading(&self) -> Option<&'a str>
Heading for the list of this command’s subcommands.
Sourcepub const fn subcommand_value_name(&self) -> Option<&'a str>
pub const fn subcommand_value_name(&self) -> Option<&'a str>
Placeholder used for a subcommand in the usage synopsis.
Sourcepub const fn next_line_help(&self) -> bool
pub const fn next_line_help(&self) -> bool
Put each argument, flag, and subcommand description on the following line.
Sourcepub const fn flatten_help(&self) -> bool
pub const fn flatten_help(&self) -> bool
Expand each visible subcommand’s summary and arguments into this command’s help page.
Sourcepub const fn term_width(&self) -> Option<u16>
pub const fn term_width(&self) -> Option<u16>
Fixed help width. Zero disables wrapping.
Sourcepub const fn max_term_width(&self) -> Option<u16>
pub const fn max_term_width(&self) -> Option<u16>
Maximum detected terminal width when term_width is unset. Zero disables the cap.
Sourcepub const fn before_help(&self) -> Option<&'a str>
pub const fn before_help(&self) -> Option<&'a str>
Text printed above the usage line, and below everything else.
The spec’s before_help/after_help and their long forms. mise puts an Examples
section in after_long_help on 115 commands, which is where the reference renders it
from — so a help page without these is missing the part a reader came for.
pub const fn before_long_help(&self) -> Option<&'a str>
pub const fn after_help(&self) -> Option<&'a str>
pub const fn after_long_help(&self) -> Option<&'a str>
pub const fn examples(&self) -> &'a [Example<'a>]
Sourcepub const fn headings(&self) -> &'a [HeadingMeta<'a>]
pub const fn headings(&self) -> &'a [HeadingMeta<'a>]
Prose for this command’s help sections, by heading title.
Sourcepub const fn outputs(&self) -> &'a [OutputMeta<'a>]
pub const fn outputs(&self) -> &'a [OutputMeta<'a>]
What this command writes, and how a consumer should read it.
Sourcepub const fn select(&self) -> Option<&'a str>
pub const fn select(&self) -> Option<&'a str>
The flag whose value picks among Self::outputs, e.g. --format.
Sourcepub const fn exit_codes(&self) -> &'a [ExitCodeMeta<'a>]
pub const fn exit_codes(&self) -> &'a [ExitCodeMeta<'a>]
What this command’s exit statuses mean.
Trait Implementations§
Source§impl<'a> Clone for CommandMeta<'a>
impl<'a> Clone for CommandMeta<'a>
Source§fn clone(&self) -> CommandMeta<'a>
fn clone(&self) -> CommandMeta<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more