diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-03-13 21:04:06 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-03-19 14:48:09 +0100 |
commit | df740ac63a2eae960321195bf405e37a0c0ccda9 (patch) | |
tree | 345f8bdba5df504a94c93798eb9ebeceb7f4b72a /imag-store/src/retrieve.rs | |
parent | 80945fcd16f053b90e387fc4fd74d978216486e6 (diff) |
Adapt to new function interface of build_entry_path()
Diffstat (limited to 'imag-store/src/retrieve.rs')
-rw-r--r-- | imag-store/src/retrieve.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/imag-store/src/retrieve.rs b/imag-store/src/retrieve.rs index 6a00dfc2..c2c2764a 100644 --- a/imag-store/src/retrieve.rs +++ b/imag-store/src/retrieve.rs @@ -1,6 +1,7 @@ use std::path::PathBuf; use std::ops::Deref; use std::fmt::Display; +use std::process::exit; use clap::ArgMatches; use toml::Value; @@ -8,22 +9,31 @@ use toml::Value; use libimagstore::store::FileLockEntry; use libimagstore::storeid::build_entry_path; use libimagrt::runtime::Runtime; +use libimagutil::trace::trace_error; pub fn retrieve(rt: &Runtime) { rt.cli() .subcommand_matches("retrieve") .map(|scmd| { - let path = scmd.value_of("id").map(|id| build_entry_path(rt, id)).unwrap(); - debug!("path = {:?}", path); - rt.store() - // "id" must be present, enforced via clap spec - .retrieve(path) - .map(|e| print_entry(rt, scmd, e)) - .map_err(|e| { - debug!("No entry."); - debug!("{}", e); - }) + scmd.value_of("id") + .map(|id| { + let path = build_entry_path(rt.store(), id); + if path.is_err() { + trace_error(&path.err().unwrap()); + exit(1); + } + let path = path.unwrap(); + debug!("path = {:?}", path); + rt.store() + // "id" must be present, enforced via clap spec + .retrieve(path) + .map(|e| print_entry(rt, scmd, e)) + .map_err(|e| { + debug!("No entry."); + debug!("{}", e); + }) + }) }); } |