From a6512c1dc52c013b6b3c25840058d8a9085b0cc1 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 29 Jul 2023 13:12:07 +0200 Subject: Support -v, and make -d imply -v --- src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') 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), 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, -- cgit v1.2.3