-
Notifications
You must be signed in to change notification settings - Fork 255
Expand file tree
/
Copy pathui.rs
More file actions
39 lines (34 loc) · 991 Bytes
/
Copy pathui.rs
File metadata and controls
39 lines (34 loc) · 991 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
39
/// Emit a message in the cargo style with a green "verb" up front and some text afterwards.
#[macro_export]
macro_rules! task_message {
($verb:expr, $($fmt:tt)+) => {
eprint!("{:>12} ", colored::Colorize::bold(colored::Colorize::green($verb)));
eprintln!($($fmt)+);
};
}
#[macro_export]
macro_rules! warning {
($($fmt:tt)+) => {
eprint!("{}", colored::Colorize::bold(colored::Colorize::yellow("Warning")));
eprint!("{}", colored::Colorize::bold(": "));
eprintln!("{}", colored::Colorize::bold(&*format!($($fmt)+)));
};
}
pub fn print_error(e: anyhow::Error) {
use colored::Colorize as _;
eprintln!(
"{}{}{}",
"Error".red().bold(),
": ".bold(),
e.to_string().bold()
);
eprintln!();
for cause in e.chain().skip(1) {
eprintln!(
"{}{}{}",
"Caused by".yellow().bold(),
": ".bold(),
cause.to_string().bold()
);
}
}