Support command line parameters

This commit is contained in:
2022-11-11 17:00:10 +01:00
parent ff5bbca3a8
commit 39747613bc
6 changed files with 35 additions and 23 deletions

View File

@@ -100,13 +100,13 @@ impl<T: ErrorString> std::convert::From<T> for Error {
}
}
pub fn open_output_file(output_path: PathBuf) -> Result<BufWriter<std::fs::File>, Error> {
pub fn open_output_file(output_path: &PathBuf) -> Result<BufWriter<std::fs::File>, Error> {
Ok(std::io::BufWriter::new(std::fs::File::create(output_path)?))
}
pub fn open_output(output_file: Option<PathBuf>) -> Result<Output, Error> {
match output_file {
Some(output_path) => Ok(Box::new(open_output_file(output_path)?)),
Some(output_path) => Ok(Box::new(open_output_file(&output_path)?)),
None => Ok(Box::new(BufWriter::new(std::io::stdout()))),
}
}