diff --git a/bin/core/imag-store/src/get.rs b/bin/core/imag-store/src/get.rs index 0c2aa132..051b7029 100644 --- a/bin/core/imag-store/src/get.rs +++ b/bin/core/imag-store/src/get.rs @@ -20,30 +20,24 @@ use std::path::PathBuf; use libimagrt::runtime::Runtime; -use libimagerror::trace::{trace_error, trace_error_exit}; +use libimagerror::trace::trace_error_exit; use libimagstore::storeid::StoreId; use retrieve::print_entry; pub fn get(rt: &Runtime) { - rt.cli() - .subcommand_matches("get") - .map(|scmd| { - scmd.value_of("id") - .map(|id| { - let path = PathBuf::from(id); - let path = match StoreId::new(Some(rt.store().path().clone()), path) { - Err(e) => trace_error_exit(&e, 1), - Ok(p) => p, - }; - debug!("path = {:?}", path); + let scmd = rt.cli().subcommand_matches("get").unwrap(); - match rt.store().get(path) { - Ok(Some(entry)) => print_entry(rt, scmd, entry), - Ok(None) => info!("No entry found"), - Err(e) => trace_error(&e), - } - }) - }); + 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!("path = {:?}", path); + + let _ = match rt.store().get(path) { + Ok(Some(entry)) => print_entry(rt, scmd, entry), + Ok(None) => info!("No entry found"), + Err(e) => trace_error_exit(&e, 1), + }; } diff --git a/bin/core/imag-store/src/ui.rs b/bin/core/imag-store/src/ui.rs index ff014f25..291518e9 100644 --- a/bin/core/imag-store/src/ui.rs +++ b/bin/core/imag-store/src/ui.rs @@ -111,8 +111,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .about("Get an entry from the store (fails if non-existent)") .version("0.1") .arg(Arg::with_name("id") - .long("id") - .short("i") + .index(1) .takes_value(true) .required(true) .help("Retrieve by Store Path, where root (/) is the store itself")