Expand description
Clap CLI introspection utilities for emitting a deterministic CLI spec JSON contract.
Responsibilities:
- Convert an in-memory
clap::Command(including hidden/internal commands and args) into the versionedCliSpeccontract model. - Produce deterministic output by sorting commands/args and by emitting a stable JSON shape.
Not handled here:
- Adding a user-facing CLI command that prints the spec (it is currently exposed only as the
hidden/internal
ralph __cli-speccommand). - File IO, stdout/stderr printing, or schema generation.
Invariants/assumptions:
- The caller provides the fully constructed clap command (e.g.
Cli::command()). - Output ordering is deterministic: args are sorted by
id, subcommands byname.
Functionsยง
- cli_
spec_ from_ command - Convert a clap command tree into the versioned
CliSpecmodel. - cli_
spec_ json_ pretty_ from_ command - Convert a clap command tree into deterministic pretty JSON.