remove bad error messages, enable multiple input paths
This commit is contained in:
parent
6c35d32acf
commit
0eb45bab22
24
src/main.rs
24
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() {
|
||||
|
|
Loading…
Reference in New Issue