1const RESET: &str = "\x1b[0m";
2const DIM: &str = "\x1b[2m";
3const CYAN: &str = "\x1b[36m";
4const RED: &str = "\x1b[31m";
5
6pub struct Report {
7 summary: String,
8 details: Vec<String>,
9}
10
11impl Report {
12 pub fn new(summary: impl Into<String>) -> Self {
13 Self {
14 summary: summary.into(),
15 details: Vec::new(),
16 }
17 }
18
19 pub fn detail(mut self, detail: impl Into<String>) -> Self {
20 self.details.push(detail.into());
21 self
22 }
23
24 pub fn summary(&self) -> &str {
25 &self.summary
26 }
27}
28
29pub fn print(report: &Report) {
30 eprintln!("{CYAN}o-{RESET} {}", report.summary);
31 for detail in &report.details {
32 eprintln!("{DIM}- {detail}{RESET}");
33 }
34}
35
36pub fn print_error(report: &Report) {
37 eprintln!("{RED}error{RESET} {}", report.summary);
38 for detail in &report.details {
39 eprintln!("{DIM}- {detail}{RESET}");
40 }
41}