Expand description
OperatorView — the shape every operator-facing introspection
mode shares.
Three callers reach this shape in sui-spec-inventory:
--flake-lock <path>(lock_file primitive)--narinfo <path>(narinfo primitive)--registry-resolve <ref>(registry primitive)
Each one (a) consumes a string input, (b) calls a typed
substrate primitive that returns Result<T, SpecError>, and
(c) renders T as a Nord-styled banner + body + optional
summary line. Third-site rule per the PRIME DIRECTIVE — the
trait extraction earns its keep when the next mode (e.g.
--realisation-parse, --substituter-probe) adds one
impl block instead of replicating banner / table / summary
plumbing.
§Anatomy of an operator view
<glyph> <header> <subject> <- emit_banner
(blank)
<body row>
<body row> <- emit_body
...
(blank)
<summary line> <- emit_summary (optional)Implementors only own parse() + body(). Banner + summary
defaults match the cppnix-style output the inventory tool
already emits.
§Why a trait
- One place for the banner shape — operators see consistent output across every mode.
- New introspection modes are 1 impl + 1
matcharm in CLI plumbing. No more cut-paste of the Nord styling. - Test harness in CSE style: a single property test asserts every implementor emits a banner first, body second, summary last (or nothing).
Traits§
- Operator
View - One operator-facing introspection view. Implementors plug into the inventory CLI to surface a typed substrate primitive.
Functions§
- pick_
format - Helper that loads a substrate primitive by name from a
load_canonical()Vec. Most inventory modes do exactly this to obtain the format spec they parse against. - render
- Helper that renders
viewend-to-end: banner, blank, body, blank, summary.
Type Aliases§
- View
Result - Common error path for inventory CLIs. Lifts
SpecErrorandio::Errorinto a singleBox<dyn Error>consumers can?against.