From 16d9e3eb600e0fa48461414f8d134e4268e318ed Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 8 Sep 2017 03:47:04 -0700 Subject: [PATCH] Colored text for artifacts --- Cargo.toml | 1 + src/language.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06cc547..2383ddd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,5 @@ getopts = "*" linefeed = "0.2.2" lazy_static = "0.2.8" maplit = "*" +colored = "1.5" diff --git a/src/language.rs b/src/language.rs index b7ceb2f..957e70e 100644 --- a/src/language.rs +++ b/src/language.rs @@ -1,3 +1,7 @@ +extern crate colored; + +use self::colored::*; + #[derive(Debug)] pub struct TokenError { pub msg: String, @@ -42,7 +46,8 @@ impl ReplOutput { pub fn to_string(&self) -> String { let mut acc = String::new(); 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 @@ -69,11 +74,12 @@ pub struct CompilationOutput { pub struct TraceArtifact { stage_name: String, debug_output: String, + text_color: &'static str, } impl 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" } } }