You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLI: introduce a JSON-vs-text output helper to collapse ad hoc --json branching #773
Across apps/rocm/src, the --json flag pattern is implemented ad hoc at every call site rather than through any shared trait or helper: roughly 93 if json { ... } else { ... }-shaped branches and 23 raw serde_json::to_string/to_string_pretty calls, each command re-deriving its own if json { serde_json::to_string_pretty(&value)? } else { manual_text_rendering(&value) }. Representative sites: main.rs:2136-2167, main.rs:2745, main.rs:2827, main.rs:3150-3227, storage.rs:901.
Unlike the other shared-component opportunities filed alongside this one, this is a larger-footprint change — retrofitting 20+ existing call sites in one PR would be a lot of unrelated churn in a single diff. Suggest scoping this one to: (1) introduce a small trait, e.g. trait JsonOrText { fn render_text(&self) -> String; } plus a print_json_or_text(json: bool, value: &impl Serialize + JsonOrText) helper, (2) require new commands to use it, and (3) migrate existing call sites incrementally as they're touched for other reasons, rather than as one bulk retrofit PR.
This is one of a handful of shared-component opportunities surfaced in an audit of the CLI's output layer (see AGENTS.md's "Shared UI components" section) — filed as a standalone issue for maintainers to weigh in on scope/approach before any implementation starts.
Documentation: once a trait/helper lands here (in whatever form maintainers settle on), add a bullet for it to AGENTS.md's "Shared UI components" section (CLI group) — the ad hoc-everywhere state this issue describes is exactly what that section exists to prevent.
Activity
refactor(cli): add a JSON-or-text output helper and migrate two commands
refactor(cli): print `rocm storage report` through print_json_or_text…
style(cli): apply rustfmt to the JsonOrText helper and its diagnose view
refactor(cli): add a JSON-or-text output helper and migrate two commands
refactor(cli): print `rocm storage report` through print_json_or_text…
style(cli): apply rustfmt to the JsonOrText helper and its diagnose view
refactor(cli): add a JSON-or-text output helper and migrate two comma…