- takes input-file, copies to output-file
This commit is contained in:
2021-09-29 11:05:57 +02:00
committed by Raymon Zutekouw
parent eae4045c28
commit 269bdf0389
3 changed files with 253 additions and 2 deletions
+26 -2
View File
@@ -1,3 +1,27 @@
fn main() {
println!("Hello, world!");
use std::fs::File;
use std::io::Write;
use anyhow::{Context, Result};
use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
#[structopt(parse(from_os_str))]
input_file: std::path::PathBuf,
#[structopt(parse(from_os_str))]
output_file: std::path::PathBuf,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::from_args();
let content = std::fs::read_to_string(&args.input_file)
.with_context(|| format!("could not read source file {:?}", args.input_file))?;
let mut out = File::create(args.output_file)?;
out.write_all(&content.as_bytes())?;
out.sync_all()?;
Ok(())
}