From 0fbf3f2522b14570a36164173ac2d63f30ee16ff Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 22 Jul 2024 15:32:59 -0400 Subject: [PATCH] failures now report time too --- src/operation.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/operation.rs b/src/operation.rs index 8d1d5b2..c340623 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -64,13 +64,14 @@ pub fn apply(targets: &Vec>) { // copy and print let result = fs::copy(source, destination); + let time = time(start); if result.is_err() { - println!(" {BOLD}{FAILURE}failed to copy{RESET}"); + print!(" {BOLD}{FAILURE}failed to copy{RESET}"); } else { - let time = time(start); - println!(" {BOLD}{SUCCESS}completed{RESET} {FAINT}({time}){RESET}"); + print!(" {BOLD}{SUCCESS}completed{RESET}"); } + println!(" {FAINT}({time}){RESET}"); } let time = time(start); println!("{FAINT}(apply: {time}){RESET}"); @@ -109,23 +110,23 @@ pub fn build(targets: &Vec>, template_dir: String, config: &C let content = read_to_string(path).unwrap(); let template = engine.compile(&content); + let compile_time = time(compile_start); + print!(" {FAINT}({compile_time}){RESET}"); if let Err(error) = template { println!("\n {BOLD}{FAILURE}failed to compile template:{RESET}\n {FAILURE}{error}\n {BOLD}skipping{RESET}"); continue; - } - let compile_time = time(compile_start); - println!(" {FAINT}({compile_time}){RESET}"); + } else { println!(); } // render let render_start = SystemTime::now(); print!(" {ITALIC}rendering{RESET}"); let render = template.unwrap().render(&engine, &context).to_string(); + let render_time = time(render_start); + print!(" {FAINT}({render_time}){RESET}"); if let Err(error) = render { println!("\n {BOLD}{FAILURE}failed to render template:{RESET}\n {FAILURE}{error}\n {BOLD}skipping{RESET}"); continue; - } - let render_time = time(render_start); - println!(" {FAINT}({render_time}){RESET}"); + } else { println!(); } // get rendered text and open destination file let output = render.unwrap();