Skip to content

Commit

Permalink
Do not output on stdout when outputting to a file (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoltesDigital authored Jun 23, 2023
1 parent b805115 commit 9c3e76d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ fn main() -> Result<(), String> {
rendered = Tera::one_off(&template, context, autoescape).unwrap();
}

println!("{rendered}");

if let Some(out_file) = output {
debug!("Saving to {}", out_file.display());
let mut file = File::create(out_file).expect("Failed opening output file");
return file.write_all(rendered.as_bytes()).map_err(|e| e.to_string());
file.write_all(rendered.as_bytes()).map_err(|e| e.to_string())
} else {
println!("{rendered}");
Ok(())
}

Ok(())
}

0 comments on commit 9c3e76d

Please sign in to comment.