From 234ac70c4e2bfb9581e5f7b01ba06629cfa3b2cb Mon Sep 17 00:00:00 2001 From: Tristan Guichaoua <33934311+tguichaoua@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:59:21 +0100 Subject: [PATCH] feat: make `time` command less noisy (#56) --- src/template/run_multi.rs | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/template/run_multi.rs b/src/template/run_multi.rs index f0e2d03..5bafefb 100644 --- a/src/template/run_multi.rs +++ b/src/template/run_multi.rs @@ -10,28 +10,29 @@ use super::{ pub fn run_multi(days_to_run: &HashSet, is_release: bool, is_timed: bool) -> Option { let mut timings: Vec = Vec::with_capacity(days_to_run.len()); - all_days().for_each(|day| { - if day > 1 { - println!(); - } - - println!("{ANSI_BOLD}Day {day}{ANSI_RESET}"); - println!("------"); - - if !days_to_run.contains(&day) { - println!("Skipped."); - return; - } - - let output = child_commands::run_solution(day, is_timed, is_release).unwrap(); - - if output.is_empty() { - println!("Not solved."); - } else { - let val = child_commands::parse_exec_time(&output, day); - timings.push(val); - } - }); + let mut need_space = false; + + // NOTE: use non-duplicate, sorted day values. + all_days() + .filter(|day| days_to_run.contains(day)) + .for_each(|day| { + if need_space { + println!(); + } + need_space = true; + + println!("{ANSI_BOLD}Day {day}{ANSI_RESET}"); + println!("------"); + + let output = child_commands::run_solution(day, is_timed, is_release).unwrap(); + + if output.is_empty() { + println!("Not solved."); + } else { + let val = child_commands::parse_exec_time(&output, day); + timings.push(val); + } + }); if is_timed { let timings = Timings { data: timings };