chore: preservation behaviour more consistent with the usual rm
This commit is contained in:
parent
76cb110e95
commit
c5d90ce069
18
src/main.rs
18
src/main.rs
|
@ -8,10 +8,6 @@ use std::{io, io::Write};
|
||||||
#[command(version, about, long_about = None, author)]
|
#[command(version, about, long_about = None, author)]
|
||||||
/// A simple, featureful and blazingly fast memory-safe alternative to 'rm' written in Rust.
|
/// A simple, featureful and blazingly fast memory-safe alternative to 'rm' written in Rust.
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Don't try to preserve '~' or '/'
|
|
||||||
#[arg(long)]
|
|
||||||
no_preserve: bool,
|
|
||||||
|
|
||||||
/// Ask once before removing all
|
/// Ask once before removing all
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
ask_once: bool,
|
ask_once: bool,
|
||||||
|
@ -68,21 +64,7 @@ fn vaporise() -> Result<()> {
|
||||||
confirm_once();
|
confirm_once();
|
||||||
}
|
}
|
||||||
|
|
||||||
let root: &str;
|
|
||||||
if cfg!(windows) {
|
|
||||||
root = "C:\\";
|
|
||||||
} else if cfg!(unix) {
|
|
||||||
root = "/";
|
|
||||||
} else {
|
|
||||||
root = "N/A";
|
|
||||||
}
|
|
||||||
|
|
||||||
for target in args.targets.iter() {
|
for target in args.targets.iter() {
|
||||||
if !args.no_preserve && target == root {
|
|
||||||
println!("{} you're trying to delete the root directory ({})! specify '{}' if you really want to do this", "error:".red().bold(), "--no-preserve".yellow(), target);
|
|
||||||
process::exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.ask_each {
|
if args.ask_each {
|
||||||
confirm_each(target);
|
confirm_each(target);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue