Merge pull request #617 from matthiasbeyer/imag-store/refactor-unwraps
Imag store/refactor unwraps
This commit is contained in:
commit
b6ce57418e
5 changed files with 16 additions and 25 deletions
|
@ -36,11 +36,10 @@ pub fn create(rt: &Runtime) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
let path = build_entry_path(rt.store(), path.unwrap());
|
||||
if path.is_err() {
|
||||
trace_error_exit(&path.unwrap_err(), 1);
|
||||
}
|
||||
let path = path.unwrap();
|
||||
let path = match build_entry_path(rt.store(), path.unwrap()) {
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
Ok(p) => p,
|
||||
};
|
||||
debug!("path = {:?}", path);
|
||||
|
||||
if scmd.subcommand_matches("entry").is_some() {
|
||||
|
|
|
@ -10,11 +10,8 @@ pub fn delete(rt: &Runtime) {
|
|||
.map(|sub| {
|
||||
sub.value_of("id")
|
||||
.map(|id| {
|
||||
let path = build_entry_path(rt.store(), id);
|
||||
if path.is_err() {
|
||||
trace_error_exit(&path.unwrap_err(), 1);
|
||||
}
|
||||
let path = path.unwrap();
|
||||
let path = try!(build_entry_path(rt.store(), id)
|
||||
.map_err(|e| trace_error_exit(&e, 1)));
|
||||
debug!("Deleting file at {:?}", id);
|
||||
|
||||
rt.store()
|
||||
|
|
|
@ -10,11 +10,10 @@ pub fn get(rt: &Runtime) {
|
|||
.map(|scmd| {
|
||||
scmd.value_of("id")
|
||||
.map(|id| {
|
||||
let path = build_entry_path(rt.store(), id);
|
||||
if path.is_err() {
|
||||
trace_error_exit(&path.unwrap_err(), 1);
|
||||
}
|
||||
let path = path.unwrap();
|
||||
let path = match build_entry_path(rt.store(), id) {
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
Ok(p) => p,
|
||||
};
|
||||
debug!("path = {:?}", path);
|
||||
|
||||
match rt.store().get(path) {
|
||||
|
|
|
@ -12,11 +12,8 @@ pub fn retrieve(rt: &Runtime) {
|
|||
.map(|scmd| {
|
||||
scmd.value_of("id")
|
||||
.map(|id| {
|
||||
let path = build_entry_path(rt.store(), id);
|
||||
if path.is_err() {
|
||||
trace_error_exit(&path.unwrap_err(), 1);
|
||||
}
|
||||
let path = path.unwrap();
|
||||
let path = try!(build_entry_path(rt.store(), id)
|
||||
.map_err(|e| trace_error_exit(&e, 1)));
|
||||
debug!("path = {:?}", path);
|
||||
|
||||
rt.store()
|
||||
|
|
|
@ -12,11 +12,10 @@ pub fn update(rt: &Runtime) {
|
|||
.map(|scmd| {
|
||||
scmd.value_of("id")
|
||||
.map(|id| {
|
||||
let path = build_entry_path(rt.store(), id);
|
||||
if path.is_err() {
|
||||
trace_error_exit(&path.unwrap_err(), 1);
|
||||
}
|
||||
let path = path.unwrap();
|
||||
let path = match build_entry_path(rt.store(), id) {
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
Ok(p) => p,
|
||||
};
|
||||
|
||||
rt.store()
|
||||
.retrieve(path)
|
||||
|
|
Loading…
Reference in a new issue