diff --git a/bin/core/imag-store/src/delete.rs b/bin/core/imag-store/src/delete.rs index 7b9e56ed..4c63bfe2 100644 --- a/bin/core/imag-store/src/delete.rs +++ b/bin/core/imag-store/src/delete.rs @@ -21,29 +21,22 @@ use std::path::PathBuf; use libimagrt::runtime::Runtime; use libimagerror::trace::MapErrTrace; +use libimagerror::trace::trace_error_exit; use libimagstore::storeid::StoreId; -use libimagutil::warn_exit::warn_exit; use libimagutil::warn_result::*; pub fn delete(rt: &Runtime) { - rt.cli() - .subcommand_matches("delete") - .map(|sub| { - sub.value_of("id") - .map(|id| { - let path = PathBuf::from(id); - let path = try!(StoreId::new(Some(rt.store().path().clone()), path) - .map_err_trace_exit(1)); - debug!("Deleting file at {:?}", id); + let scmd = rt.cli().subcommand_matches("delete").unwrap(); + let id = scmd.value_of("id").unwrap(); // safe by clap + let path = PathBuf::from(id); + let store = Some(rt.store().path().clone()); + let path = StoreId::new(store, path).unwrap_or_else(|e| trace_error_exit(&e, 1)); + debug!("Deleting file at {:?}", id); - rt.store() - .delete(path) - .map_warn_err(|e| format!("Error: {:?}", e)) - .map_err_trace_exit(1) - }) - .or_else(|| warn_exit("No ID passed. Will exit now", 1)) - }) - .or_else(|| warn_exit("No subcommand 'delete'. Will exit now", 1)); + let _ = rt.store() + .delete(path) + .map_warn_err(|e| format!("Error: {:?}", e)) + .map_err_trace_exit(1); } #[cfg(test)] diff --git a/bin/core/imag-store/src/ui.rs b/bin/core/imag-store/src/ui.rs index 291518e9..73b259bd 100644 --- a/bin/core/imag-store/src/ui.rs +++ b/bin/core/imag-store/src/ui.rs @@ -179,8 +179,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .about("Delete an entry from the store") .version("0.1") .arg(Arg::with_name("id") - .long("id") - .short("i") + .index(1) .takes_value(true) .required(true) .help("Remove Store Entry with this path. Root (/) is the store itself")