Fix: List ids sorted
This commit is contained in:
parent
c27dc79afe
commit
532de484f2
1 changed files with 18 additions and 10 deletions
|
@ -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()]
|
||||||
|
});
|
||||||
|
|
||||||
|
for id in ids {
|
||||||
|
writeln!(rt.stdout(), "{}", id)
|
||||||
.to_exit_code()
|
.to_exit_code()
|
||||||
.unwrap_or_exit();
|
.unwrap_or_exit();
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue