aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-06 20:23:50 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-06 20:23:50 +0200
commitd3b0e3e93f4636bb6cceb148536c914106e486f7 (patch)
treee339d69eba873ffd090629766b2a285cc8e4a5cc /src
parentce5c445fd431f108e73bbe62b0ee73b8418d85c1 (diff)
Improve the -d flag
Now when performing a dry run, you are shown the direct move from src to dst. This is a lot more helpful since the end user doesn’t really care about whatever temporary folder we store things in; the user just wants to make sure the command he’s about to execute will do what he expects.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 23a0bf6..cca7c87 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -156,11 +156,17 @@ fn work() -> Result<(), io::Error> {
come first. */
ps.sort_by_key(|s| Reverse(s.0.components().count()));
- for (s, t, _) in ps.iter() {
- move_path(&flags, &s, &t);
- }
- for (_, t, d) in ps.iter().rev() {
- move_path(&flags, &t, &d);
+ if flags.dryrun {
+ for (s, _, d) in ps {
+ println!("{} -> {}", s.as_path().display(), d.as_path().display());
+ }
+ } else {
+ for (s, t, _) in ps.iter() {
+ move_path(&flags, &s, &t);
+ }
+ for (_, t, d) in ps.iter().rev() {
+ move_path(&flags, &t, &d);
+ }
}
Ok(())
@@ -175,10 +181,7 @@ 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;
- flags.verbose = true;
- }
+ Short('d') | Long("dryrun") => flags.dryrun = true,
Short('e') | Long("encode") => flags.encode = true,
Short('i') | Long("individual") => flags.individual = true,
Short('v') | Long("verbose") => flags.verbose = true,