From 8345de8f0c96d7f44856fd7b3373c73e0214a8b4 Mon Sep 17 00:00:00 2001 From: Emi Simpson Date: Wed, 17 Aug 2022 23:03:33 -0400 Subject: [PATCH] Don't overwrite files without the -f/--force flag --- src/main.rs | 1 + src/parse.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 95d2ac2..d70822c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -253,6 +253,7 @@ fn download(server: &str, args: DownloadArgs) -> Result<(), AviaryDownloadError> .write(true) .truncate(true) .create(true) + .create_new(!args.force) .open(&path) .map_err(|e| match e.kind() { io::ErrorKind::PermissionDenied => diff --git a/src/parse.rs b/src/parse.rs index 1e276ac..714b0d8 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -61,4 +61,8 @@ pub struct DownloadArgs { /// /// A directory will be generated based on the name of the gallery if this is not set pub output: Option, + + #[argh(switch, short='f')] + /// overwrite any existing files in the output directory + pub force: bool, }