Expand description
Renderer split formalization (A8).
The CLI is already structure-first: every verb builds a
#[derive(Serialize)] output struct, then routes through
should_output_json to either serde_json::to_writer or a
hand-written text renderer. This module codifies that pattern as a
trait, plus an emit helper, so future verbs can’t drift back to
println! at call sites.
Adding a new verb: define struct FooOutput { ... } deriving
Serialize, impl RenderOutput for FooOutput { fn render_text(...) },
then call emit(&cli, repo.config(), &output) from the handler.
Structs§
- Render
Opts - Optional knobs the text renderer respects. New options append at the tail; defaults stay backwards-compatible.
- Repository
Context Info - Repository
Presentation
Traits§
- Render
Output - Contract every CLI output type implements. The
Serializesuper-trait is what powers--output json;render_textis the human view. The same underlying value powers both — there is no separate “text-mode” code path that could drift from JSON.
Functions§
- actor_
display - Format an
actorpayload (provider,model) into a one-line display. Suppresses the literal “unknown” placeholder. ReturnsNonewhen neither side carries a real value — callers should suppress theActor:line entirely in that case. - emit
- Resolve the format decision (JSON vs text) and emit accordingly.
- emit_
with_ opts - Same as
emitbut lets the caller pass non-default render options (e.g.RenderOpts { short: true, .. }forlog --oneline). - git_
only_ branch_ summary - preview_
list - Format a truncated one-line preview of an ordered string list for
inclusion in a status / advice / blocker message. Used by every
verb that would otherwise dump a 50+ item csv onto a single line:
branch lists in
status/log/show/diagnose, heavy-impact path lists instatus/snapshot/thread/merge, and theHeavy-impact change:blocker built inrepo::thread_advice. - real_
or_ none - Treat the harness “unknown” placeholder and empty/whitespace strings
as absent so renderers don’t surface them as literal text. Mirrors
the discipline in
snapshot::clean_attribution_value— the harness writes “unknown” when it can’t identify provider/model from argv/env, and rendering that literally asanthropic/unknownis worse than just showing the meaningful side. - repository_
mode_ label - Human-facing repository mode label. JSON keeps the exact
repository_capability/storage_modelvalues; text output uses product language instead of storage implementation names. - repository_
presentation - Presentation-only repository identity. This deliberately leaves
Repository::capability_label()untouched: an isolated checkout that shares a Git-overlay object store is still technically opened through the native Heddle storage path, but user-facing status should say what the checkout is managed by. - shell_
quote - POSIX-shell-quote a path for inclusion in a copy-pasteable command.
- write_
json_ stdout - Write a single JSON value plus trailing newline to stdout.
- write_
stdout - Write text to stdout, treating
BrokenPipeas a normal shell outcome.