iq_cli/
macros.rs

1//! Macros for generating status messages using the global static SHELL
2
3/// Print a status message with the given color (if colors are enabled)
4#[macro_export]
5macro_rules! status {
6    ($color:expr, $status:expr, $msg:expr) => {
7        $crate::status($color, $status, $msg, true);
8    };
9    ($color:expr, $status:expr, $fmt:expr, $($arg:tt)+) => {
10        $crate::status($color, $status, format!($fmt, $($arg)+), true);
11    };
12}
13
14/// Print a success status message (in green if colors are enabled)
15#[macro_export]
16macro_rules! status_ok {
17    ($status:expr, $msg:expr) => {
18        $crate::status($crate::color::GREEN, $status, $msg, true);
19    };
20    ($status:expr, $fmt:expr, $($arg:tt)+) => {
21        $crate::status($crate::color::GREEN, $status, format!($fmt, $($arg)+), true);
22    };
23}
24
25/// Print a warning message (in yellow if colors are enabled)
26#[macro_export]
27macro_rules! status_warn {
28    ($msg:expr) => {
29        $crate::status($crate::color::YELLOW, "warning:", $msg, false);
30    };
31    ($fmt:expr, $($arg:tt)+) => {
32        $crate::status($crate::color::YELLOW, "warning:", format!($fmt, $($arg)+), false);
33    };
34}
35
36/// Print an error message (in red if colors are enabled)
37#[macro_export]
38macro_rules! status_error {
39    ($msg:expr) => {
40        $crate::status($crate::color::RED, "error:", $msg, false);
41    };
42    ($fmt:expr, $($arg:tt)+) => {
43        $crate::status($crate::color::RED, "error:", format!($fmt, $($arg)+), false);
44    };
45}