From c6e905a79f7ba083b3f97728aa3a74fb0e03661b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 May 2019 13:42:34 +0300 Subject: Colorize Rust code as HTML --- crates/ra_cli/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_cli/src') diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index f11d0e6bd..93aba4c70 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs @@ -3,7 +3,7 @@ mod analysis_stats; use std::io::Read; use clap::{App, Arg, SubCommand}; -use ra_ide_api::file_structure; +use ra_ide_api::{file_structure, Analysis}; use ra_syntax::{SourceFile, TreeArc, AstNode}; use flexi_logger::Logger; use ra_prof::profile; @@ -16,6 +16,7 @@ fn main() -> Result<()> { .setting(clap::AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump"))) .subcommand(SubCommand::with_name("symbols")) + .subcommand(SubCommand::with_name("highlight")) .subcommand( SubCommand::with_name("analysis-stats") .arg(Arg::with_name("verbose").short("v").long("verbose")) @@ -38,6 +39,11 @@ fn main() -> Result<()> { println!("{:?}", s); } } + ("highlight", _) => { + let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); + let html = analysis.highlight_as_html(file_id).unwrap(); + println!("{}", html); + } ("analysis-stats", Some(matches)) => { let verbose = matches.is_present("verbose"); let path = matches.value_of("path").unwrap_or(""); -- cgit v1.2.3