aoc_toolkit/cli/output/
progress.rs1pub mod markdown;
2
3use crate::application::progress::{
4 DayAvailability, EditionProgress, SolverRegistration, VerifiedStar,
5};
6use crate::application::run::PartStatus;
7
8pub(crate) fn print_snapshot(year: usize, source: &str, timestamp: u64) {
9 println!("{year}: {source} star snapshot (last synced at Unix timestamp {timestamp})");
10}
11
12pub(crate) fn print_missing_snapshot(year: usize) {
13 println!("{year}: No verified star snapshot available");
14}
15
16pub(crate) fn print_edition(report: &EditionProgress) {
17 if report.synced_at_unix_seconds.is_some() {
18 println!(
19 "Verified stars: {}/{} ยท Completed days: {}/{}",
20 report.earned_stars(),
21 report.possible_stars(),
22 report.completed_days(),
23 report.days.len(),
24 );
25 }
26
27 println!("Day | Availability | Solver | Local P1 | Local P2 | Star P1 | Star P2");
28
29 for day in &report.days {
30 println!(
31 "{:02} | {} | {} | {} | {} | {} | {}",
32 day.local.day,
33 availability_label(day.local.availability),
34 registration_label(day.local.registration),
35 execution_label(day.local.part_one),
36 execution_label(day.local.part_two),
37 star_label(day.star_one),
38 star_label(day.star_two),
39 );
40 }
41}
42
43fn availability_label(availability: DayAvailability) -> &'static str {
44 match availability {
45 DayAvailability::Unlocked => "Unlocked",
46 DayAvailability::Locked => "Locked",
47 DayAvailability::OutsideEdition => "Outside edition",
48 }
49}
50
51fn registration_label(registration: SolverRegistration) -> &'static str {
52 match registration {
53 SolverRegistration::Registered => "Registered",
54 SolverRegistration::Unregistered => "Unregistered",
55 SolverRegistration::Unknown => "Unknown",
56 }
57}
58
59fn execution_label(status: Option<PartStatus>) -> &'static str {
60 match status {
61 Some(PartStatus::Succeeded) => "Succeeded",
62 Some(PartStatus::Panicked) => "Panicked",
63 None => "No run",
64 }
65}
66
67fn star_label(star: VerifiedStar) -> &'static str {
68 match star {
69 VerifiedStar::Earned => "Earned",
70 VerifiedStar::Missing => "Missing",
71 VerifiedStar::Unknown => "Unknown",
72 }
73}
74
75pub(crate) fn print_readme_result(changed: bool) {
76 if changed {
77 println!("Updated README progress section");
78 } else {
79 println!("README progress section is already up to date");
80 }
81}