aoc_toolkit/cli/output/
fetch.rs1use crate::InputSource;
2use crate::application::fetch::FetchReport;
3
4pub(crate) fn print_fetch_report(reports: &[FetchReport], show_summary: bool) {
5 let mut cached = 0;
6 let mut downloaded = 0;
7 let mut failed = 0;
8
9 for report in reports {
10 match &report.outcome {
11 Ok(source) => {
12 let status = match source {
13 InputSource::Cached => {
14 cached += 1;
15 "Cached"
16 }
17 InputSource::Downloaded => {
18 downloaded += 1;
19 "Downloaded"
20 }
21 };
22
23 println!("✓ {} / Day {:02} — {}", report.year, report.day, status);
24 }
25 Err(error) => {
26 failed += 1;
27
28 eprintln!("✗ {} / Day {:02} — {}", report.year, report.day, error);
29 }
30 }
31 }
32
33 if show_summary {
34 println!();
35 println!("Fetch summary");
36 println!(" Cached : {cached}");
37 println!(" Downloaded : {downloaded}");
38 println!(" Failed : {failed}");
39 }
40}