Skip to main content

Module cli

Module cli 

Source
Expand description

The veks-completion CLI framework: argument parsing, help, and a command definition model — the in-tree replacement for clap.

This is the runtime half. A command’s CLI is described by a CommandSpec (subcommands, options, positionals); parse turns an argv slice into a ParsedArgs; render_help renders --help. The derive macro (veks-completion-derive) generates the CommandSpec and the typed extraction from this same model, so one declaration drives parsing, help, and completion (the completion CommandTree is built from the very same CommandSpec).

The option’s parse-defining shape is the existing OptionDef — shared and consistency-checked across commands. Per-command facets that may legitimately vary (required-ness, default value) live on OptionSpec, deliberately outside the shape that the consistency audit compares.

Structs§

CommandSpec
A command and (recursively) its subcommands. The single source consumed by the parser, the help renderer, and the completion-tree builder.
OptionSpec
One option as it appears on a specific command: the shared OptionDef shape plus this command’s required-ness, default, and value completer.
ParsedArgs
The result of parsing one command level. Values are kept as strings (the derive macro performs typed conversion); repeatable options accumulate.
PositionalSpec
A positional argument.

Enums§

ParseError
A parse failure, with enough context to render a useful message.

Traits§

VeksCli
Implemented by #[derive(VeksCli)] types: a command/args struct or a subcommand enum. Provides the CommandSpec (drives parse + help + completion) and the typed extraction from a ParsedArgs.

Functions§

build_completion_tree
Build a completion CommandTree from a CommandSpec — the same spec that drives parsing and help. This replaces walking a clap::Command: one definition now feeds parse + help + complete.
parse
Parse argv (the words after the program name) against spec.
render_help
Render --help text for a command spec, formatted comparably to clap: about, usage, aliases, commands, arguments, options (with an auto -h, --help), and any after_help.
render_help_for
Render --help for the deepest subcommand named by the leading words of argv, so app group leaf --help shows the leaf’s options rather than the group overview. Stops descending at the first flag (or unknown word) and renders whatever level was reached (the root when argv names none).