Add color to bin/gen error messages

type: development
This commit is contained in:
Casey Rodarmor 2020-04-29 22:56:34 -07:00
parent 8dfdbe43df
commit 60a72cf057
No known key found for this signature in database
GPG Key ID: 556186B153EC6FE0
4 changed files with 7 additions and 2 deletions

1
Cargo.lock generated
View File

@ -358,6 +358,7 @@ checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
name = "gen"
version = "0.0.0"
dependencies = [
"ansi_term 0.12.1",
"askama",
"cargo_toml",
"chrono",

View File

@ -6,6 +6,7 @@ edition = "2018"
publish = false
[dependencies]
ansi_term = "0.12.1"
askama = "0.9.0"
cargo_toml = "0.8.0"
chrono = "0.4.11"
@ -13,6 +14,7 @@ fehler = "1.0.0"
git2 = "0.13.1"
globset = "0.4.5"
ignore = "0.4.14"
lexiclean = "0.0.1"
libc = "0.2.69"
log = "0.4.8"
pretty_env_logger = "0.4.0"
@ -24,7 +26,6 @@ strum = "0.18.0"
strum_macros = "0.18.0"
tempfile = "3.1.0"
walkdir = "2.3.1"
lexiclean = "0.0.1"
[dependencies.serde]
version = "1.0.106"

View File

@ -11,6 +11,7 @@ pub(crate) use std::{
str,
};
pub(crate) use ansi_term::Style;
pub(crate) use askama::Template;
pub(crate) use cargo_toml::Manifest;
pub(crate) use chrono::{DateTime, NaiveDateTime, Utc};

View File

@ -34,7 +34,9 @@ fn main() {
pretty_env_logger::init();
if let Err(error) = Opt::from_args().run() {
eprintln!("{}", error);
let bold = Style::new().bold();
let red = Style::new().fg(ansi_term::Color::Red).bold();
eprintln!("{}: {}", red.paint("error"), bold.paint(error.to_string()));
process::exit(EXIT_FAILURE);
}
}