aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2019-12-07 16:20:27 +0100
committerDaniel Schadt <kingdread@gmx.de>2019-12-07 16:20:27 +0100
commiteb79920efd704fdf1863785b6740a2eb060aad0c (patch)
tree4a7c84f9ce96ede2beff09940b9a3e3d6b8c22cb /src/main.rs
parent9bd3c2da26b48d1ae2fc84b39bc5ef6844bd4e45 (diff)
downloadkondou-eb79920efd704fdf1863785b6740a2eb060aad0c.tar.gz
kondou-eb79920efd704fdf1863785b6740a2eb060aad0c.tar.bz2
kondou-eb79920efd704fdf1863785b6740a2eb060aad0c.zip
basic color support
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 10 insertions, 1 deletions
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);