openclaw_scan/output/mod.rs
1//! Output dispatching — terminal (human-readable) or JSON.
2
3pub mod json;
4pub mod terminal;
5
6use crate::report::Report;
7
8/// Output configuration derived from CLI flags.
9#[derive(Debug, Clone)]
10pub struct OutputConfig {
11 /// Emit machine-readable JSON instead of the rich terminal view.
12 pub json: bool,
13 /// Suppress the banner and progress; show findings only.
14 pub quiet: bool,
15 /// Include per-finding remediation and evidence in terminal output.
16 pub verbose: bool,
17 /// Disable ANSI colour codes (auto-disabled when stdout is not a tty).
18 pub color: bool,
19}
20
21impl Default for OutputConfig {
22 fn default() -> Self {
23 OutputConfig {
24 json: false,
25 quiet: false,
26 verbose: false,
27 color: true,
28 }
29 }
30}
31
32/// Render `report` to stdout according to `cfg`.
33pub fn render(report: &Report, cfg: &OutputConfig) -> anyhow::Result<()> {
34 if cfg.json {
35 json::print(report)
36 } else {
37 terminal::print(report, cfg)
38 }
39}