console_decorate/
lib.rs

1pub mod prelude {
2    pub use super::{
3        decorate, BG_BLUE, BG_GREEN, BG_GREY, BG_NONE, BG_PINK, BG_RED, BG_TEAL, BG_WHITE,
4        BG_YELLOW, BLUE, BOLD, GREEN, GREY, ITALICS, PINK, RED, STRIKETHROUGH, TEAL, UNDERLINE,
5        WHITE, YELLOW,
6    };
7}
8
9pub const BOLD: &str = "1";
10pub const UNDERLINE: &str = "4";
11pub const ITALICS: &str = "3";
12pub const STRIKETHROUGH: &str = "9";
13
14pub const GREY: &str = "90";
15pub const RED: &str = "91";
16pub const GREEN: &str = "92";
17pub const YELLOW: &str = "93";
18pub const BLUE: &str = "94";
19pub const PINK: &str = "95";
20pub const TEAL: &str = "96";
21pub const WHITE: &str = "97";
22
23pub const BG_NONE: &str = "99";
24pub const BG_GREY: &str = "100";
25pub const BG_RED: &str = "101";
26pub const BG_GREEN: &str = "102";
27pub const BG_YELLOW: &str = "103";
28pub const BG_BLUE: &str = "104";
29pub const BG_PINK: &str = "105";
30pub const BG_TEAL: &str = "106";
31pub const BG_WHITE: &str = "107";
32
33#[macro_export]
34macro_rules! decorate {
35    ($str:expr, $($constant:path),*) => {{
36        let mut s = String::from("");
37        $(
38            s = format!("{}{}", s, format!("\x1b[{}m", $constant));
39        )*
40        format!("{}{}{}", s, $str, "\x1b[0m")
41    }};
42}