livery.toolroom.bench._toolspec¶
livery.toolroom.bench._toolspec ¶
What a command-line tool says about itself — extracted, not transcribed.
The tools.* bridge translates keyword arguments mechanically, which is
what keeps it from going stale the way hand-written wrappers do. But two
things about a tool cannot be derived from the call: what its options
mean, and how it spells a negation.
The second one is a bug, not a nicety. off emits --no-<name>, which
is right for most tools and wrong for enough to matter: mkdocs build
--no-clean is rejected outright — the flag is --dirty — and five of
mkdocs' eight negatable options disagree with the convention. Only the
tool knows, so footman asks it.
Extraction, richest first:
- click —
Command.paramscarriesopts,secondary_opts(the true negation), the default, the help text, and the type, as data. No parsing, no guessing. - argparse / optparse — walk the parser's actions (to come).
--helptext — for the Rust and Go tools, whose output is regular and which often spell the negation in prose (clap: "Use--no-unsafe-fixesto disable"). To come.
Nothing here runs on the completion hot path, and nothing here is
imported by tools.py at call time: the extracted facts are recorded,
and the extractor only runs when a reading is taken. The data classes
it fills, livery.toolroom.store.ToolSpec and its parts, live in the
store, which renders them; this module is the reading side.
Functions:
| Name | Description |
|---|---|
from_click |
A |
from_click ¶
A ToolSpec from a click Group or Command.
click models a negatable flag as one parameter with opts and
secondary_opts — --clean / --dirty — which is exactly the fact
off needs and cannot infer.