quotch 0.5.4

Fast cross-platform CLI for AI coding-agent usage limits
use crate::model::{Output, Snapshot};
use chrono::Utc;

pub fn render(snapshots: Vec<Snapshot>, include_raw: bool) -> String {
    let snapshots = if include_raw {
        snapshots
    } else {
        snapshots
            .into_iter()
            .map(|mut s| {
                s.raw = None;
                s
            })
            .collect()
    };

    let output = Output {
        v: 1,
        generated_at: Utc::now(),
        snapshots,
    };

    match serde_json::to_string_pretty(&output) {
        Ok(mut s) => {
            s.push('\n');
            s
        }
        Err(_) => "{}".to_string(),
    }
}