Add functionality to list diaries
This commit is contained in:
parent
bed49b6ece
commit
6e80f603d6
3 changed files with 29 additions and 0 deletions
|
@ -26,6 +26,7 @@ chrono = "0.4"
|
|||
log = "0.4.0"
|
||||
toml = "0.4"
|
||||
toml-query = "0.6"
|
||||
itertools = "0.7"
|
||||
|
||||
libimagerror = { version = "0.8.0", path = "../../../lib/core/libimagerror" }
|
||||
libimagstore = { version = "0.8.0", path = "../../../lib/core/libimagstore" }
|
||||
|
|
|
@ -37,6 +37,7 @@ extern crate clap;
|
|||
extern crate chrono;
|
||||
extern crate toml;
|
||||
extern crate toml_query;
|
||||
extern crate itertools;
|
||||
|
||||
extern crate libimagdiary;
|
||||
extern crate libimagentryedit;
|
||||
|
@ -47,9 +48,14 @@ extern crate libimagstore;
|
|||
extern crate libimagtimeui;
|
||||
extern crate libimagutil;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
use libimagrt::setup::generate_runtime_setup;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagerror::trace::MapErrTrace;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
mod create;
|
||||
mod delete;
|
||||
mod edit;
|
||||
|
@ -76,6 +82,7 @@ fn main() {
|
|||
.map(|name| {
|
||||
debug!("Call {}", name);
|
||||
match name {
|
||||
"diaries" => diaries(&rt),
|
||||
"create" => create(&rt),
|
||||
"delete" => delete(&rt),
|
||||
"edit" => edit(&rt),
|
||||
|
@ -92,3 +99,20 @@ fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
fn diaries(rt: &Runtime) {
|
||||
use libimagdiary::diary::Diary;
|
||||
use libimagerror::io::ToExitCode;
|
||||
use libimagerror::exit::ExitUnwrap;
|
||||
use libimagerror::iter::TraceIterator;
|
||||
|
||||
let out = rt.stdout();
|
||||
let mut outlock = out.lock();
|
||||
|
||||
rt.store()
|
||||
.diary_names()
|
||||
.map_err_trace_exit_unwrap(1)
|
||||
.trace_unwrap_exit(1)
|
||||
.unique()
|
||||
.for_each(|n| writeln!(outlock, "{}", n).to_exit_code().unwrap_or_exit())
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
|||
.required(false)
|
||||
.help("Use other than default diary"))
|
||||
|
||||
.subcommand(SubCommand::with_name("diaries")
|
||||
.about("List all available diaries")
|
||||
.version("0.1"))
|
||||
|
||||
.subcommand(SubCommand::with_name("create")
|
||||
.about("Create a diary entry")
|
||||
.version("0.1")
|
||||
|
|
Loading…
Reference in a new issue