whyno-cli 0.3.0

Linux permission debugger
//! Output formatting dispatch.
//!
//! Three modes: checklist (default), json (structured), explain (verbose).
//! `render` dispatches to the appropriate formatter.

pub mod checklist;
pub mod explain;
pub mod json;

mod layer_name;

use std::io::Write;

use whyno_core::checks::CheckReport;
use whyno_core::fix::FixPlan;
use whyno_core::state::SystemState;

use crate::error::OutputError;

/// Output mode selection.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OutputMode {
    /// Human-readable `[PASS]`/`[FAIL]`/`[SKIP]` checklist.
    Checklist,
    /// Structured JSON (schema v1).
    Json,
    /// Verbose resolution chain for debugging.
    Explain,
}

/// Renders check report and fix plan in specified mode.
///
/// Writes to `writer` (not hardcoded to stdout) for testability.
pub fn render(
    report: &CheckReport,
    plan: &FixPlan,
    state: &SystemState,
    mode: OutputMode,
    writer: &mut dyn Write,
) -> Result<(), OutputError> {
    match mode {
        OutputMode::Checklist => checklist::render(report, plan, state, writer),
        OutputMode::Json => json::render(report, plan, state, writer),
        OutputMode::Explain => explain::render(report, plan, state, writer),
    }
}