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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

#[macro_export]
macro_rules! errors_and_exit {
    ($fmt:expr) => {
        {
            errors!($fmt);
            exit!(1);
        }
    };
    ($fmt:expr, $($arg:tt)+) => {
        {
            errors!($fmt, $($arg)+);
            exit!(1);
        }
    }
}

#[macro_export]
macro_rules! exit {
    ($code:expr) => (::std::process::exit($code))
}

#[macro_export]
macro_rules! infos {
    ($fmt:expr) => {logs!($crate::color::Color::White, $fmt)};
    ($fmt:expr, $($arg:tt)+) => {logs!($crate::color::Color::White, $fmt, $($arg)+)}
}

#[macro_export]
macro_rules! warns {
    ($fmt:expr) => {logs!($crate::color::Color::Yellow, $fmt)};
    ($fmt:expr, $($arg:tt)+) => {logs!($crate::color::Color::Yellow, $fmt, $($arg)+)}
}

#[macro_export]
macro_rules! errors {
    ($fmt:expr) => {
        {
            $crate::color::print("error: ", $crate::color::Color::Red);
            $crate::color::println($fmt.to_string(), $crate::color::Color::White);
        }
    };
    ($fmt:expr, $($arg:tt)+) => {
        {
            $crate::color::print("error: ", $crate::color::Color::Red);
            $crate::color::println(format!($fmt, $($arg)+), $crate::color::Color::White);
        }
    }
}

#[macro_export]
macro_rules! logs {
    ($color:expr, $fmt:expr) => {
        {
            $crate::color::print("    ", $color);
            $crate::color::println($fmt.to_string(), $color);
        }
    };
    ($color:expr, $fmt:expr, $($arg:tt)+) => {
        {
            $crate::color::print("    ", $color);
            $crate::color::println(format!($fmt, $($arg)+), $color);
        }
    }
}