1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use console::{Style, Term};
use once_cell::sync::Lazy;
use paste::paste;

pub static TERM_ERR: Lazy<Term> = Lazy::new(|| Term::stderr());
pub static TERM_OUT: Lazy<Term> = Lazy::new(|| Term::stdout());

macro_rules! color {
    ($color:ident) => {
        paste! {
            pub static [<ERR_ $color:upper>]: Lazy<Style> = Lazy::new(|| Style::new().for_stderr().$color());
            pub static [<ERR_ $color:upper _BOLD>]: Lazy<Style> = Lazy::new(|| Style::new().for_stderr().$color().bold());
            pub static [<OUT_ $color:upper>]: Lazy<Style> = Lazy::new(|| Style::new().$color());
            pub static [<OUT_ $color:upper _BOLD>]: Lazy<Style> = Lazy::new(|| Style::new().$color().bold());
        }
    };
}

color!(black);
color!(red);
color!(green);
color!(yellow);
color!(blue);
color!(magenta);
color!(cyan);
color!(white);