Skip to main content

Module spec

Module spec 

Source
Expand description

Cold-path metadata, and writing it out as a spec.

The tables in the crate root are what a parse reads: names, shorts, whether a flag takes a value. Everything else a CLI knows about itself — help text, choices, defaults, what a command does to the world — lives here instead, in a parallel tree that points at those tables.

Two reasons for the split. A successful parse never touches any of this, so keeping it out of the hot tables keeps them dense; and a CLI that wants only a parser does not compile it at all, since this module is behind the spec feature.

What the metadata does not do is repeat the tables. FlagMeta borrows the Flag it describes, so long and short forms have exactly one definition and cannot drift from what the parser matches.

§Emitting

Everything here lowers into the spec without loss, which is deliberate: a field the spec cannot express would make the emitted KDL a summary rather than a definition. When something is missing the spec gains it first — help_heading went in that way.

Structs§

AdmonitionMeta
Structured explanatory text that each renderer adapts to its output format.
ArgMeta
What a positional argument knows about itself beyond how it parses.
ArgumentState
Presence information exposed across a flattened CommandArgs boundary.
Candidate
Something a shell could offer at the cursor.
ChoiceAliasMeta
ChoiceMeta
ClauseMeta
Cold metadata for a command’s compiled clause table.
CommandMeta
What a command knows about itself beyond how it parses.
CommandOverlay
One sparse metadata override applied by SpecView.
CompleteCtx
What a completion callback is told about the cursor.
DefaultIf
A default that applies when another flag is given.
DefaultViewOmitter
The omission policy used by generated executable-view entry points.
Example
A worked example, for documentation.
ExitCodeMeta
One documented exit status.
FlagMeta
What a flag knows about itself beyond how it parses.
FlattenGroup
A run of one command’s flags that arrived from a flattened Args type.
GroupMeta
A set of one command’s arguments that relate to one another as a set.
HeadingMeta
Prose introducing one help section.
OutputMeta
One thing a command can write.
RequiredIfEq
A selector/value comparison used by conditional requiredness.
RequiresIf
A flag required when the declaring flag is explicitly given value.
Spec
A whole CLI: the root command plus what describes the program itself.
SpecView
A borrowed, sparse view over a derive-generated Spec.
ViewMeta
A named executable surface emitted into the portable spec.

Enums§

AdmonitionKind
The significance of an explanatory block attached to an argument.
CandidateKind
The semantic role of one completion candidate.
CommandSelector
A command selected for a cold-path metadata override.
Effect
What running a command does to the world.
Framing
The wire format of what a command writes to stdout.
SettingGiven
One value a flag was given, in a vocabulary this crate can hold.

Traits§

ArgGroup
An enum whose variants are one command’s related flags.
CommandArgs
Omitted
Supplies a typed placeholder for fields outside an executable view.
Subcommands
An enum whose variants are a command’s subcommands.
ValueEnum
A struct that describes one command’s flags and arguments.
ViewCommandArgs
View-aware construction for a derived command or flattened argument group.
ViewSubcommands
View-aware construction for a derived subcommand enum.

Functions§

choice_matches
choice_values
Convert every repeated value of one ValueEnum field, reporting name for the first word that is not one of the declared values.
concat_aliases
Join command alias lists at compile time.
concat_arg_metas
Join groups of argument metadata into one, at compile time.
concat_bindings
The bindings of several commands, joined into one array.
concat_flag_metas
Join groups of flag metadata into one, at compile time.
concat_group_metas
Join groups of group metadata into one, at compile time.
flag_selector_count
How many flags on command accept selector.
view_for_program
The declared executable view selected by argv0, if any.

Type Aliases§

Completer
A function that answers for one argument or flag value.