diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-07-29 13:12:07 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-07-29 13:12:07 +0200 |
commit | a6512c1dc52c013b6b3c25840058d8a9085b0cc1 (patch) | |
tree | d901f1702f62f80e6cc5a0f126c28ec9d44dc0d3 | |
parent | 1c5f7db2f8b53650f9b00757f432201d9b952180 (diff) |
Support -v, and make -d imply -v
-rw-r--r-- | src/main.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index b6170ae..bf695cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,17 +134,21 @@ fn work() -> Result<(), Error> { ps.sort_by_key(|s| Reverse(s.0.components().count())); for (s, t, _) in ps.iter() { - if flags.dryrun { + if flags.verbose { println!("{} -> {}", s.as_path().display(), t.as_path().display()); - } else { + } + + if !flags.dryrun { copy_and_remove_file_or_dir(&s, &t)?; } } for (_, t, d) in ps.iter().rev() { - if flags.dryrun { + if flags.verbose { println!("{} -> {}", t.as_path().display(), d.as_path().display()); - } else { + } + + if !flags.dryrun { copy_and_remove_file_or_dir(&t, &d)?; } } @@ -161,7 +165,10 @@ fn parse_args() -> Result<(Flags, Vec<OsString>), lexopt::Error> { while let Some(arg) = parser.next()? { match arg { Short('0') | Long("nul") => flags.nul = true, - Short('d') | Long("dryrun") => flags.dryrun = true, + Short('d') | Long("dryrun") => { + flags.dryrun = true; + flags.verbose = true; + }, Short('e') | Long("encode") => flags.encode = true, Short('i') | Long("individual") => flags.individual = true, Short('v') | Long("verbose") => flags.verbose = true, |