-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmacros.rs
More file actions
38 lines (31 loc) · 942 Bytes
/
Copy pathmacros.rs
File metadata and controls
38 lines (31 loc) · 942 Bytes
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
use owo_colors::{Color, OwoColorize};
use std::error::Error;
use std::io::Write;
macro_rules! ok {
($title:expr, $msg:expr) => {
$crate::macros::print::<owo_colors::colors::Green>($title, $msg)
};
($title:expr, $msg:expr, $($arg:tt)*) => {
ok!($title, format!($msg, $($arg)*).as_str())
};
}
macro_rules! info {
($title:expr, $msg:expr) => {
$crate::macros::print::<owo_colors::colors::Cyan>($title, $msg)
};
($title:expr, $msg:expr, $($arg:tt)*) => {
info!($title, format!($msg, $($arg)*).as_str())
};
}
macro_rules! error {
($title:expr, $msg:expr) => {
$crate::macros::print::<owo_colors::colors::Red>($title, $msg)
};
($title:expr, $msg:expr, $($arg:tt)*) => {
error!($title, format!($msg, $($arg)*).as_str())
};
}
pub(super) fn print<C: Color>(title: &str, msg: &str) {
print!("{:<15}", msg.fg::<C>());
println!(" {}", msg);
}