diff --git a/src/main.rs b/src/main.rs index 33eada1..0578c09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -273,6 +273,13 @@ fn main() -> Result<(), Box> { .help("edited document file") .num_args(1) .action(ArgAction::Append), + ) + .arg( + Arg::new("remove") + .help("remove document file on successful update") + .short('r') + .num_args(0) + .action(ArgAction::SetTrue), ), ); @@ -786,6 +793,14 @@ fn main() -> Result<(), Box> { // collect attachments before printing so they are included in output s.collect_attachments(&conn)?; s.print(); + + // remove modified document file if requested + if sub_matches.get_flag("remove") { + match std::fs::remove_file(file) { + Ok(_) => eprintln!("removed {}", file), + Err(e) => eprintln!("error removing file {}: {}", file, e), + } + } } else { eprintln!("update failed"); std::process::exit(1);