From c90e3499e508de80b6797639aeb90bd1cf647e19 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Wed, 30 Dec 2015 09:07:01 +0100 Subject: [PATCH] Add color support --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f3c5877..c1fd06a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,8 @@ use std::io::{BufRead, BufReader}; use std::fs::File; use std::{env, process}; +use ansi_term::Colour; + mod types; mod tokenizer; @@ -32,8 +34,8 @@ fn print_lines(tokenizer: &mut Tokenizer) where R: BufRead { LineType::Empty => println!(""), LineType::Title(_) => debug!("Ignoring title"), LineType::Description(text) => println!(" {}", text), - LineType::ExampleText(text) => println!(" - {}", text), - LineType::ExampleCode(text) => println!(" {}", text), + LineType::ExampleText(text) => println!(" {}", Colour::Green.paint(format!("- {}", text))), + LineType::ExampleCode(text) => println!(" {}", Colour::Cyan.paint(format!(" {}", text))), LineType::Other(text) => debug!("Unknown line type: {:?}", text), } } @@ -72,6 +74,7 @@ fn main() { // Print output print_lines(&mut tokenizer); + println!(""); }