Colored text for artifacts

This commit is contained in:
greg 2017-09-08 03:47:04 -07:00
parent 737dad6438
commit 16d9e3eb60
2 changed files with 9 additions and 2 deletions

View File

@ -12,4 +12,5 @@ getopts = "*"
linefeed = "0.2.2" linefeed = "0.2.2"
lazy_static = "0.2.8" lazy_static = "0.2.8"
maplit = "*" maplit = "*"
colored = "1.5"

View File

@ -1,3 +1,7 @@
extern crate colored;
use self::colored::*;
#[derive(Debug)] #[derive(Debug)]
pub struct TokenError { pub struct TokenError {
pub msg: String, pub msg: String,
@ -42,7 +46,8 @@ impl ReplOutput {
pub fn to_string(&self) -> String { pub fn to_string(&self) -> String {
let mut acc = String::new(); let mut acc = String::new();
for line in self.artifacts.iter() { for line in self.artifacts.iter() {
acc.push_str(&line.debug_output); acc.push_str(&line.debug_output.color(line.text_color).to_string());
acc.push_str(&"\n");
} }
acc.push_str(&self.output); acc.push_str(&self.output);
acc acc
@ -69,11 +74,12 @@ pub struct CompilationOutput {
pub struct TraceArtifact { pub struct TraceArtifact {
stage_name: String, stage_name: String,
debug_output: String, debug_output: String,
text_color: &'static str,
} }
impl TraceArtifact { impl TraceArtifact {
pub fn new(stage: &str, debug: String) -> TraceArtifact { pub fn new(stage: &str, debug: String) -> TraceArtifact {
TraceArtifact { stage_name: stage.to_string(), debug_output: debug } TraceArtifact { stage_name: stage.to_string(), debug_output: debug, text_color: "blue" }
} }
} }