Optimize implementation

Code-wise, the functionality was not changed. The changes only make the
code much more pretty.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-11-04 22:28:47 +01:00
parent 5210985bf4
commit d004c667fd

View file

@ -19,7 +19,7 @@
use std::process::exit; use std::process::exit;
use chrono::naive::NaiveDateTime; use chrono::naive::NaiveDateTime as NDT;
use libimagdiary::diaryid::DiaryId; use libimagdiary::diaryid::DiaryId;
use libimagrt::runtime::Runtime; use libimagrt::runtime::Runtime;
@ -44,17 +44,10 @@ pub fn delete(rt: &Runtime) {
.value_of("datetime") .value_of("datetime")
.map(|dt| { debug!("DateTime = {:?}", dt); dt }) .map(|dt| { debug!("DateTime = {:?}", dt); dt })
.and_then(DateTime::parse) .and_then(DateTime::parse)
.map(|dt| dt.into()) .map(Into::into)
.ok_or_else(|| { .ok_or_else(|| warn_exit("Not deleting entries: missing date/time specification", 1))
warn!("Not deleting entries, because missing date/time specification"); .and_then(|dt: NDT| DiaryId::from_datetime(diaryname.clone(), dt).into_storeid())
exit(1); .and_then(|id| rt.store().retrieve(id))
})
.and_then(|dt: NaiveDateTime| {
DiaryId::from_datetime(diaryname.clone(), dt)
.into_storeid()
.map(|id| rt.store().retrieve(id))
.map_err_trace_exit_unwrap(1)
})
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.get_location() .get_location()
.clone(); .clone();