cli_animate/
utils.rs

1#[derive(Debug)]
2pub enum Color {
3    White,
4    Red,
5    Blue,
6    Yellow,
7    Green,
8    Cyan,
9    Magenta,
10    Black,
11}
12
13impl Color {
14    pub fn to_ansi_code(&self) -> &'static str {
15        match self {
16            Color::White => "\x1b[37m",
17            Color::Red => "\x1b[31m",
18            Color::Blue => "\x1b[34m",
19            Color::Yellow => "\x1b[33m",
20            Color::Green => "\x1b[32m",
21            Color::Cyan => "\x1b[36m",
22            Color::Magenta => "\x1b[35m",
23            Color::Black => "\x1b[30m",
24        }
25    }
26}