#[macro_export]
macro_rules! ceprint {
($title:expr, $msg:expr => $color:ident) => {{
$crate::Color::$color;
eprint!("{}", $crate::cformat!($title, $msg => $color))
}};
($title:expr, $msg:expr => ($r:expr, $g:expr, $b:expr)) => {{
$crate::Color::TrueColor { r: $r, g: $g, b: $b };
eprint!("{}", $crate::cformat!($title, $msg => ($r, $g, $b)))
}};
($title:expr, $msg:expr) => {{
eprint!("{}", $crate::cformat!($title, $msg => Red))
}};
($msg:expr => $color:ident) => {{
$crate::Color::$color;
eprint!("{}",$crate::cformat!($msg => $color))
}};
($msg:expr => ($r:expr, $g:expr, $b:expr)) => {{
$crate::Color::TrueColor { r: $r, g: $g, b: $b };
eprint!("{}",$crate::cformat!($msg => ($r, $g, $b)))
}};
($msg:expr) => {{
eprint!("{}",$crate::cformat!($msg => Red))
}};
}
#[macro_export]
macro_rules! ceprintln {
($title:expr, $msg:expr => $color:ident) => {{
$crate::Color::$color;
eprintln!("{}", $crate::cformat!($title, $msg => $color))
}};
($title:expr, $msg:expr => ($r:expr, $g:expr, $b:expr)) => {{
$crate::Color::TrueColor { r: $r, g: $g, b: $b };
eprintln!("{}", $crate::cformat!($title, $msg => ($r, $g, $b)))
}};
($title:expr, $msg:expr) => {{
eprintln!("{}", $crate::cformat!($title, $msg => Red))
}};
($msg:expr => $color:ident) => {{
$crate::Color::$color;
eprintln!("{}", $crate::cformat!($msg => $color))
}};
($msg:expr => ($r:expr, $g:expr, $b:expr)) => {{
$crate::Color::TrueColor { r: $r, g: $g, b: $b };
eprintln!("{}", $crate::cformat!($msg => ($r, $g, $b)))
}};
($msg:expr) => {{
eprintln!("{}", $crate::cformat!($msg => Red))
}};
}
#[cfg(test)]
mod tests {
#[test]
fn ceprint_title_message_color() {
ceprint!("Failed", "to compile" => Red);
}
#[test]
fn ceprint_title_message_rgb() {
ceprint!("Failed", "to compile main.rs" => (255, 0, 0));
}
#[test]
fn ceprint_title_message() {
ceprint!("Failed", "to compile main.rs");
}
#[test]
fn ceprint_message_color() {
ceprint!("Failed to compile" => Red);
}
#[test]
fn ceprint_message_rgb() {
ceprint!("Failed to compile" => (255, 0, 0));
}
#[test]
fn ceprint_message() {
ceprint!("Failed to compile");
}
}