chore: remove need for -r

This commit is contained in:
Muhammad Nauman Raza 2024-03-14 19:19:40 +00:00
parent 53206ede2a
commit 623d932b97

View file

@ -6,10 +6,6 @@ use colored::Colorize;
#[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 {
/// Recursively delete files and directories
#[arg(short, long)]
recursive: bool,
/// Don't try to preserve '~' or '/' /// Don't try to preserve '~' or '/'
#[arg(long)] #[arg(long)]
no_preserve: bool, no_preserve: bool,
@ -37,12 +33,7 @@ fn main() -> std::io::Result<()> {
if path::Path::new(target).exists() { if path::Path::new(target).exists() {
if fs::metadata(target).unwrap().is_dir() { if fs::metadata(target).unwrap().is_dir() {
if args.recursive == false { let _ = fs::remove_dir_all(target);
println!("{} could not remove directory {}, please specify '-r'", "error:".red().bold(), target);
process::exit(0);
} else {
let _ = fs::remove_dir_all(target);
}
} else { } else {
let _ = fs::remove_file(target); let _ = fs::remove_file(target);
} }