Merge pull request #1393 from matthiasbeyer/imag-diary/list-ids-sorted

Fix: List ids sorted
This commit is contained in:
Matthias Beyer 2018-04-13 15:54:32 +02:00 committed by GitHub
commit a53f130557
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,10 @@ use libimagerror::trace::MapErrTrace;
use libimagerror::io::ToExitCode; use libimagerror::io::ToExitCode;
use libimagerror::exit::ExitUnwrap; use libimagerror::exit::ExitUnwrap;
use libimagutil::debug_result::*; use libimagutil::debug_result::*;
use libimagdiary::diaryid::DiaryId;
use libimagdiary::diaryid::FromStoreId;
use libimagdiary::error::Result;
use util::get_diary_name; use util::get_diary_name;
@ -33,17 +37,21 @@ pub fn list(rt: &Runtime) {
let diaryname = get_diary_name(rt) let diaryname = get_diary_name(rt)
.unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1)); .unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1));
Diary::entries(rt.store(), &diaryname) let mut ids = Diary::entries(rt.store(), &diaryname)
.map_dbg_str("Ok") .map_dbg_str("Ok")
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.for_each(|id| { .map(|id| DiaryId::from_storeid(&id))
writeln!(rt.stdout(), "{}", id .collect::<Result<Vec<_>>>()
.without_base() .map_err_trace_exit_unwrap(1);
.to_str()
.map_err_trace() ids.sort_by_key(|id| {
.unwrap_or(String::from("<<Path Parsing Error>>"))) [id.year() as u32, id.month(), id.day(), id.hour(), id.minute(), id.second()]
.to_exit_code() });
.unwrap_or_exit();
}) for id in ids {
writeln!(rt.stdout(), "{}", id)
.to_exit_code()
.unwrap_or_exit();
}
} }