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§
- Command
Spec - A command and (recursively) its subcommands. The single source consumed by the parser, the help renderer, and the completion-tree builder.
- Option
Spec - One option as it appears on a specific command: the shared
OptionDefshape plus this command’s required-ness, default, and value completer. - Parsed
Args - The result of parsing one command level. Values are kept as strings (the derive macro performs typed conversion); repeatable options accumulate.
- Positional
Spec - A positional argument.
Enums§
- Parse
Error - 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 theCommandSpec(drives parse + help + completion) and the typed extraction from aParsedArgs.
Functions§
- build_
completion_ tree - Build a completion
CommandTreefrom aCommandSpec— the same spec that drives parsing and help. This replaces walking aclap::Command: one definition now feeds parse + help + complete. - parse
- Parse
argv(the words after the program name) againstspec. - render_
help - Render
--helptext for a command spec, formatted comparably to clap: about, usage, aliases, commands, arguments, options (with an auto-h, --help), and anyafter_help. - render_
help_ for - Render
--helpfor the deepest subcommand named by the leading words ofargv, soapp group leaf --helpshows 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 whenargvnames none).