implemented writing to file
This commit is contained in:
parent
8b074b14b9
commit
87843b62a7
|
|
@ -1,6 +1,7 @@
|
|||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use log::error;
|
||||
use crate::model_rgb_ascii::Ascii;
|
||||
|
||||
|
|
@ -14,7 +15,7 @@ pub fn print_terminal(art: Vec<Vec<Ascii>>, in_colour: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn print_file(art: Vec<Vec<Ascii>>, out: PathBuf) -> std::io::Result<()> {
|
||||
fn _print_file(art: Vec<Vec<Ascii>>, out: PathBuf) -> std::io::Result<()> {
|
||||
let mut file = File::create_new(out)?;
|
||||
for line in art {
|
||||
for ascii in line {
|
||||
|
|
@ -23,4 +24,11 @@ pub fn print_file(art: Vec<Vec<Ascii>>, out: PathBuf) -> std::io::Result<()> {
|
|||
writeln!(file)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_file(art: Vec<Vec<Ascii>>, out: PathBuf) {
|
||||
if let Err(e) = _print_file(art, out) {
|
||||
error!("Failed to write to file: {}", e.to_string());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue