failures now report time too

This commit is contained in:
Valerie Wolfe 2024-07-22 15:32:59 -04:00
parent 6b3d12e7f9
commit 0fbf3f2522

View file

@ -64,13 +64,14 @@ pub fn apply(targets: &Vec<Map<String, Value>>) {
// 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<Map<String, Value>>, 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();