Add back color

This commit is contained in:
greg 2018-03-24 13:20:10 -07:00
parent df51a1e04a
commit 20cf877d21
2 changed files with 14 additions and 5 deletions

View File

@ -2,6 +2,7 @@ extern crate colored;
use std::collections::HashMap;
use self::colored::*;
use std::fmt::Write;
pub struct LLVMCodeString(pub String);
@ -94,7 +95,19 @@ impl UnfinishedComputation {
impl FinishedComputation {
pub fn to_repl(&self) -> String {
match self.text_output {
Ok(ref s) => s.clone(),
Ok(ref output) => {
let mut buf = String::new();
for stage in ["tokens", "parse_trace", "ast", "symbol_table", "type_check"].iter() {
if let Some(artifact) = self.artifacts.get(&stage.to_string()) {
let color = artifact.text_color;
let stage = stage.color(color).bold();
let output = artifact.debug_output.color(color);
write!(&mut buf, "{}: {}\n", stage, output);
}
}
write!(&mut buf, "{}", output);
buf
}
Err(ref s) => format!("{} {}", "Error: ".red().bold(), s)
}
}

View File

@ -6,10 +6,6 @@ extern crate getopts;
extern crate rustyline;
extern crate itertools;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;