implemented writing to file

This commit is contained in:
Djairo Hougee 2023-02-08 17:33:28 +01:00
parent 135274c9c5
commit 8b074b14b9
2 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,5 @@
#![feature(file_create_new)]
use clap::Parser; use clap::Parser;
use crate::ascii_manipulation::*; use crate::ascii_manipulation::*;
use crate::cli::Cli; use crate::cli::Cli;

View File

@ -1,4 +1,7 @@
use std::fs::File;
use std::io::Write;
use std::path::PathBuf; use std::path::PathBuf;
use log::error;
use crate::model_rgb_ascii::Ascii; use crate::model_rgb_ascii::Ascii;
//todo: take into consideration the in_colour flag //todo: take into consideration the in_colour flag
@ -11,6 +14,13 @@ pub fn print_terminal(art: Vec<Vec<Ascii>>, in_colour: bool) {
} }
} }
pub fn print_file(ascii: Vec<Vec<Ascii>>, out: PathBuf) { pub fn print_file(art: Vec<Vec<Ascii>>, out: PathBuf) -> std::io::Result<()> {
//todo: this let mut file = File::create_new(out)?;
for line in art {
for ascii in line {
write!(file, "{}", ascii.char)?;
}
writeln!(file)?;
}
Ok(())
} }