about summary refs log tree commit diff
path: root/crates/rust-analyzer/src/cli/highlight.rs
blob: 4f9b362f1bec47b430f4781a83a7b545ef0df86d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Read Rust code on stdin, print HTML highlighted version to stdout.

use ide::Analysis;

use crate::cli::{flags, read_stdin};

impl flags::Highlight {
    pub fn run(self) -> anyhow::Result<()> {
        let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
        let html = analysis.highlight_as_html(file_id, self.rainbow).unwrap();
        println!("{}", html);
        Ok(())
    }
}