radicle-cli 0.20.0

Radicle CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::path::Path;

use crate::terminal as term;

/// Pretty-print a JSON value with syntax highlighting.
pub fn to_pretty(value: &impl serde::Serialize, path: &Path) -> anyhow::Result<Vec<term::Line>> {
    let json = serde_json::to_string_pretty(&value)?;
    let mut highlighter = term::highlight::Highlighter::default();
    let highlighted = highlighter.highlight(path, json.as_bytes())?;

    Ok(highlighted)
}