Available on crate feature
surface-model only.Expand description
A CLI’s commands and flags as plain data, taken from its Clap types.
Clap remains the command grammar. Surface lists what a user of the CLI
sees, for generated documentation files and the tests that compare them
with the CLI. It holds the binary name, the mise task name, every command
and alias, every argument, the Usage KDL, and the #USAGE mount line (see
usage).
The surface-model feature builds a Surface. surface-serde adds
serialization. surface-templates adds the shared minijinja fragments
and the render function. A generated documentation file is then a
render of the CLI’s own Clap types.
Structs§
- Surface
- What a user sees of one Clap command tree.
- Surface
Argument - One positional argument or flag in a
Surface, whichSurface::newbuilds. A field can join it in a minor release. - Surface
Command - One command in a
Surface, whichSurface::newbuilds. A field can join it in a minor release.
Enums§
- Surface
Requirement - Whether Clap requires an argument, as
SurfaceArgument::requirementreports. - Surface
Scope - How far Clap propagates an argument, as
SurfaceArgument::scopereports.
Constants§
- COMMANDS_
FRAGMENT surface-templates - Template source for
ctl/commands.md.jinja: the macrocommand_inventory(surface)renders a table of the visible top-level commands, with their visible aliases and descriptions. - INVOCATION_
FRAGMENT surface-templates - Template source for
ctl/invocation.md.jinja: the macromounted_invocation(surface, examples)renders examplemise runlines and the rule that they take no--. - VERSION_
FRAGMENT surface-templates - Template source for
ctl/version.md.jinja: the macroversion_line(version)renders theversion:line of a generated file’s frontmatter.
Functions§
- add_
fragments surface-templates - Add ctl-core’s shared fragments to
environment, under the namesctl/version.md.jinja,ctl/invocation.md.jinja, andctl/commands.md.jinja. A template imports them from there. - environment
surface-templates - Create an
Environmentthat holds the shared fragments. - render
surface-templates - Render the template
source, namedname, in a freshenvironment.