diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-08-12 11:50:13 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-08-12 11:50:13 +0200 |
commit | b557886301de0eefd3296941fe29fe539b364d8f (patch) | |
tree | 8b1f9baea5e0609eda1a3f01f492836ec514a36c /src | |
parent | 345f224a9ce7029c86beae2e4ad9d1eea7c56432 (diff) |
Swap flags.nobackup for flags.backup
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 233549d..ae29006 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,16 +18,28 @@ use { tempfile::tempdir, }; -#[derive(Default)] struct Flags { + pub backup: bool, pub dryrun: bool, pub encode: bool, pub individual: bool, - pub nobackup: bool, pub nul: bool, pub verbose: bool, } +impl Default for Flags { + fn default() -> Self { + Flags { + backup: true, + dryrun: false, + encode: false, + individual: false, + nul: false, + verbose: false, + } + } +} + impl Flags { fn parse() -> Result<(Flags, Vec<OsString>), lexopt::Error> { use lexopt::prelude::*; @@ -42,7 +54,7 @@ impl Flags { Short('d') | Long("dryrun") => flags.dryrun = true, Short('e') | Long("encode") => flags.encode = true, Short('i') | Long("individual") => flags.individual = true, - Short('n') | Long("no-backup") => flags.nobackup = true, + Short('n') | Long("no-backup") => flags.backup = false, Short('v') | Long("verbose") => flags.verbose = true, Value(v) => { rest.push(v); @@ -134,7 +146,7 @@ fn work() -> Result<(), io::Error> { .collect_vec(); let mut cache_dir = PathBuf::default(); - if !flags.nobackup { + if flags.backup { let pid = process::id().to_string(); let cache_base = env::var("XDG_CACHE_HOME").unwrap_or_else(|_| { err!("XDG_CACHE_HOME variable must be set"); @@ -161,7 +173,7 @@ fn work() -> Result<(), io::Error> { } } - if !flags.nobackup { + if flags.backup { fs::remove_dir_all(cache_dir)?; } |