diff options
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 11 |
2 files changed, 11 insertions, 1 deletions
@@ -19,3 +19,4 @@ quick-error = "1.2.0" itertools = "0.8.0" md5 = "0.7" base64 = "0.11" +termcolor = "1.0" diff --git a/src/main.rs b/src/main.rs index c8afd0f..e0d0e89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,12 +6,14 @@ extern crate itertools; extern crate md5; extern crate reqwest; extern crate rusttype; +extern crate termcolor; extern crate xdg; #[macro_use] extern crate quick_error; use std::error::Error as StdError; use std::fmt; +use std::io::Write; mod api; mod bt; @@ -19,6 +21,7 @@ mod cache; mod render; use clap::{App, Arg, ArgMatches}; +use termcolor::{StandardStream, WriteColor, ColorSpec, Color, ColorChoice}; use api::{Api, Profession, Skill}; use bt::{BuildTemplate, ExtraData, Legend, TraitChoice, Traitline}; @@ -291,7 +294,13 @@ fn run() -> MainResult<()> { fn main() { let result = run(); if let Err(e) = result { - eprintln!("[Error] {}", e); + let mut error_color = ColorSpec::new(); + error_color.set_fg(Some(Color::Red)); + let mut stderr = StandardStream::stderr(ColorChoice::Auto); + stderr.set_color(&error_color); + write!(stderr, "[Error]"); + stderr.reset(); + writeln!(stderr, " {}", e); let mut source = e.source(); while let Some(s) = source { eprintln!(" caused by {}", s); |