aoc-toolkit 0.1.0-alpha.4

A toolkit for solving Advent of Code problems
Documentation
use crate::InputSource;
use crate::application::fetch::FetchReport;

pub(crate) fn print_fetch_report(reports: &[FetchReport], show_summary: bool) {
    let mut cached = 0;
    let mut downloaded = 0;
    let mut failed = 0;

    for report in reports {
        match &report.outcome {
            Ok(source) => {
                let status = match source {
                    InputSource::Cached => {
                        cached += 1;
                        "Cached"
                    }
                    InputSource::Downloaded => {
                        downloaded += 1;
                        "Downloaded"
                    }
                };

                println!("✓ {} / Day {:02} — {}", report.year, report.day, status);
            }
            Err(error) => {
                failed += 1;

                eprintln!("✗ {} / Day {:02} — {}", report.year, report.day, error);
            }
        }
    }

    if show_summary {
        println!();
        println!("Fetch summary");
        println!("  Cached     : {cached}");
        println!("  Downloaded : {downloaded}");
        println!("  Failed     : {failed}");
    }
}