From 0eb45bab22ea563cb00709ecc63a89e1ad971d29 Mon Sep 17 00:00:00 2001 From: Luca Bilke <luca@bil.ke> Date: Thu, 2 May 2024 19:37:36 +0200 Subject: [PATCH] remove bad error messages, enable multiple input paths --- src/main.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index f96346b..08ee04a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ enum Commands { /// Lists trashed files List { path: Option<PathBuf> }, /// Put a file into the trash - Put { path: PathBuf }, + Put { path: Vec<PathBuf> }, /// Restore a file by its id Restore { id: PathBuf }, /// Prune files older than n days (defaults to 7) @@ -24,10 +24,7 @@ enum Commands { } fn list<P: Fn(&trash::TrashItem) -> bool>(predicate: P) -> Vec<trash::TrashItem> { - let trashed = match trash::os_limited::list() { - Ok(t) => t, - Err(_) => panic!("Error listing trashed files"), - }; + let trashed = trash::os_limited::list().unwrap(); trashed.into_iter().filter(predicate).collect() } @@ -52,11 +49,8 @@ fn print_list(path: Option<PathBuf>) { } } -fn put(path: PathBuf) { - match trash::delete(path) { - Ok(_) => (), - Err(_) => panic!("Error trashing file"), - } +fn put(path: Vec<PathBuf>) { + trash::delete_all(path).unwrap() } fn restore(id: PathBuf) { @@ -68,10 +62,7 @@ fn restore(id: PathBuf) { _ => panic!("Multiple trashed files with that id"), } - match trash::os_limited::restore_all(items) { - Ok(_) => (), - Err(_) => panic!("Error restoring trashed file"), - } + trash::os_limited::restore_all(items).unwrap() } fn prune(max_days: Option<u64>) { @@ -81,10 +72,7 @@ fn prune(max_days: Option<u64>) { let items: Vec<trash::TrashItem> = list(predicate).into_iter().collect(); - match trash::os_limited::purge_all(items) { - Ok(_) => (), - Err(_) => panic!("Error pruning files"), - } + trash::os_limited::purge_all(items).unwrap() } fn main() {