summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-todo
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-04 21:59:54 +0200
committerGitHub <noreply@github.com>2017-09-04 21:59:54 +0200
commit6d1dab31179eb4414b45d9a94f453833ddc558ce (patch)
tree8bca1ca131e17a647a98d083087e0a42124067eb /bin/domain/imag-todo
parentf025416cf7d96b5f2a41d545c75255cab9fe2d06 (diff)
parent6583ba04a2151d940d99d4277713df4f50bf9eac (diff)
Merge pull request #1029 from matthiasbeyer/all-extensions-as-traits
All extensions as traits
Diffstat (limited to 'bin/domain/imag-todo')
-rw-r--r--bin/domain/imag-todo/src/main.rs53
1 files changed, 30 insertions, 23 deletions
diff --git a/bin/domain/imag-todo/src/main.rs b/bin/domain/imag-todo/src/main.rs
index 43545d2a..20ad60e4 100644
--- a/bin/domain/imag-todo/src/main.rs
+++ b/bin/domain/imag-todo/src/main.rs
@@ -35,7 +35,7 @@ use toml::Value;
use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup;
-use libimagtodo::task::Task;
+use libimagtodo::taskstore::TaskStore;
use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit};
mod ui;
@@ -61,9 +61,11 @@ fn tw_hook(rt: &Runtime) {
let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap();
if subcmd.is_present("add") {
let stdin = stdin();
- let stdin = stdin.lock(); // implements BufRead which is required for `Task::import()`
- match Task::import(rt.store(), stdin) {
+ // implements BufRead which is required for `Store::import_task_from_reader()`
+ let stdin = stdin.lock();
+
+ match rt.store().import_task_from_reader(stdin) {
Ok((_, line, uuid)) => println!("{}\nTask {} stored in imag", line, uuid),
Err(e) => trace_error_exit(&e, 1),
}
@@ -71,7 +73,7 @@ fn tw_hook(rt: &Runtime) {
// The used hook is "on-modify". This hook gives two json-objects
// per usage und wants one (the second one) back.
let stdin = stdin();
- Task::delete_by_imports(rt.store(), stdin.lock()).map_err_trace().ok();
+ rt.store().delete_tasks_by_imports(stdin.lock()).map_err_trace().ok();
} else {
// Should not be possible, as one argument is required via
// ArgGroup
@@ -92,30 +94,35 @@ fn list(rt: &Runtime) {
is_match!(e.kind(), &::toml_query::error::ErrorKind::IdentifierNotFoundInDocument(_))
};
- let res = Task::all(rt.store()) // get all tasks
+ let res = rt.store().all_tasks() // get all tasks
.map(|iter| { // and if this succeeded
// filter out the ones were we can read the uuid
- let uuids : Vec<_> = iter.filter_map(|t| match t {
- Ok(v) => match v.get_header().read(&String::from("todo.uuid")) {
- Ok(Some(&Value::String(ref u))) => Some(u.clone()),
- Ok(Some(_)) => {
- warn!("Header type error");
- None
- },
- Ok(None) => {
- warn!("Header missing field");
- None
+ let uuids : Vec<_> = iter.filter_map(|storeid| {
+ match rt.store().retrieve(storeid) {
+ Ok(fle) => {
+ match fle.get_header().read(&String::from("todo.uuid")) {
+ Ok(Some(&Value::String(ref u))) => Some(u.clone()),
+ Ok(Some(_)) => {
+ error!("Header type error, expected String at 'todo.uuid' in {}",
+ fle.get_location());
+ None
+ },
+ Ok(None) => {
+ error!("Header missing field in {}", fle.get_location());
+ None
+ },
+ Err(e) => {
+ if !no_identifier(&e) {
+ trace_error(&e);
+ }
+ None
+ }
+ }
},
Err(e) => {
- if !no_identifier(&e) {
- trace_error(&e);
- }
+ trace_error(&e);
None
- }
- },
- Err(e) => {
- trace_error(&e);
- None
+ },
}
})
.collect();