aoc-toolkit 0.1.0-alpha.4

A toolkit for solving Advent of Code problems
Documentation
pub mod markdown;

use crate::application::progress::{
    DayAvailability, EditionProgress, SolverRegistration, VerifiedStar,
};
use crate::application::run::PartStatus;

pub(crate) fn print_snapshot(year: usize, source: &str, timestamp: u64) {
    println!("{year}: {source} star snapshot (last synced at Unix timestamp {timestamp})");
}

pub(crate) fn print_missing_snapshot(year: usize) {
    println!("{year}: No verified star snapshot available");
}

pub(crate) fn print_edition(report: &EditionProgress) {
    if report.synced_at_unix_seconds.is_some() {
        println!(
            "Verified stars: {}/{} ยท Completed days: {}/{}",
            report.earned_stars(),
            report.possible_stars(),
            report.completed_days(),
            report.days.len(),
        );
    }

    println!("Day | Availability | Solver | Local P1 | Local P2 | Star P1 | Star P2");

    for day in &report.days {
        println!(
            "{:02} | {} | {} | {} | {} | {} | {}",
            day.local.day,
            availability_label(day.local.availability),
            registration_label(day.local.registration),
            execution_label(day.local.part_one),
            execution_label(day.local.part_two),
            star_label(day.star_one),
            star_label(day.star_two),
        );
    }
}

fn availability_label(availability: DayAvailability) -> &'static str {
    match availability {
        DayAvailability::Unlocked => "Unlocked",
        DayAvailability::Locked => "Locked",
        DayAvailability::OutsideEdition => "Outside edition",
    }
}

fn registration_label(registration: SolverRegistration) -> &'static str {
    match registration {
        SolverRegistration::Registered => "Registered",
        SolverRegistration::Unregistered => "Unregistered",
        SolverRegistration::Unknown => "Unknown",
    }
}

fn execution_label(status: Option<PartStatus>) -> &'static str {
    match status {
        Some(PartStatus::Succeeded) => "Succeeded",
        Some(PartStatus::Panicked) => "Panicked",
        None => "No run",
    }
}

fn star_label(star: VerifiedStar) -> &'static str {
    match star {
        VerifiedStar::Earned => "Earned",
        VerifiedStar::Missing => "Missing",
        VerifiedStar::Unknown => "Unknown",
    }
}

pub(crate) fn print_readme_result(changed: bool) {
    if changed {
        println!("Updated README progress section");
    } else {
        println!("README progress section is already up to date");
    }
}