1#[macro_export]
2macro_rules! color_format_if {
3 ($fmt:expr, $val:expr, $color:expr) => {
4 match $val {
5 true => $color(format!("{}", $fmt).as_str()),
6 false => format!("{}", $fmt).normal().clear(),
7 }
8 };
9}
10
11#[macro_export]
12macro_rules! warn_format_if {
13 ($fmt:expr, $val:expr) => {
14 color_format_if!($fmt, $val, colored::Colorize::yellow)
15 };
16}
17
18#[macro_export]
19macro_rules! alert_format_if {
20 ($fmt:expr, $val:expr) => {
21 color_format_if!($fmt, $val, colored::Colorize::red)
22 };
23}
24
25#[macro_export]
26macro_rules! warn_format {
27 ($fmt:expr) => {
28 color_format_if!($fmt, true, colored::Colorize::yellow)
29 };
30}
31
32#[macro_export]
33macro_rules! alert_format {
34 ($fmt:expr) => {
35 color_format_if!($fmt, true, colored::Colorize::red)
36 };
37}