radicle_cli/terminal/
json.rs

1use std::path::Path;
2
3use crate::terminal as term;
4
5/// Pretty-print a JSON value with syntax highlighting.
6pub fn to_pretty(value: &impl serde::Serialize, path: &Path) -> anyhow::Result<Vec<term::Line>> {
7    let json = serde_json::to_string_pretty(&value)?;
8    let mut highlighter = term::highlight::Highlighter::default();
9    let highlighted = highlighter.highlight(path, json.as_bytes())?;
10
11    Ok(highlighted)
12}