Refactor imag-todo to work with the TaskStore trait instead of Task
This commit is contained in:
parent
58a2729da0
commit
0f317858e2
2 changed files with 4 additions and 7 deletions
|
@ -22,6 +22,5 @@ is-match = "0.1.*"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
|
||||||
libimagrt = { version = "0.4.0", path = "../../../lib/core/libimagrt" }
|
libimagrt = { version = "0.4.0", path = "../../../lib/core/libimagrt" }
|
||||||
libimagstore = { version = "0.4.0", path = "../../../lib/core/libimagstore" }
|
|
||||||
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
|
libimagerror = { version = "0.4.0", path = "../../../lib/core/libimagerror" }
|
||||||
libimagtodo = { version = "0.4.0", path = "../../../lib/domain/libimagtodo" }
|
libimagtodo = { version = "0.4.0", path = "../../../lib/domain/libimagtodo" }
|
||||||
|
|
|
@ -25,7 +25,6 @@ extern crate toml_query;
|
||||||
#[macro_use] extern crate version;
|
#[macro_use] extern crate version;
|
||||||
|
|
||||||
extern crate libimagrt;
|
extern crate libimagrt;
|
||||||
extern crate libimagstore;
|
|
||||||
extern crate libimagerror;
|
extern crate libimagerror;
|
||||||
extern crate libimagtodo;
|
extern crate libimagtodo;
|
||||||
|
|
||||||
|
@ -36,8 +35,7 @@ use toml::Value;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagtodo::task::TaskStore;
|
||||||
use libimagtodo::task::Task;
|
|
||||||
use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit};
|
use libimagerror::trace::{MapErrTrace, trace_error, trace_error_exit};
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
@ -65,7 +63,7 @@ fn tw_hook(rt: &Runtime) {
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
let stdin = stdin.lock(); // implements BufRead which is required for `FileLockEntry::import_task_from_reader()`
|
let stdin = stdin.lock(); // implements BufRead which is required for `FileLockEntry::import_task_from_reader()`
|
||||||
|
|
||||||
match FileLockEntry::import_task_from_reader(rt.store(), stdin) {
|
match rt.store().import_task_from_reader(stdin) {
|
||||||
Ok((_, line, uuid)) => println!("{}\nTask {} stored in imag", line, uuid),
|
Ok((_, line, uuid)) => println!("{}\nTask {} stored in imag", line, uuid),
|
||||||
Err(e) => trace_error_exit(&e, 1),
|
Err(e) => trace_error_exit(&e, 1),
|
||||||
}
|
}
|
||||||
|
@ -73,7 +71,7 @@ fn tw_hook(rt: &Runtime) {
|
||||||
// The used hook is "on-modify". This hook gives two json-objects
|
// The used hook is "on-modify". This hook gives two json-objects
|
||||||
// per usage und wants one (the second one) back.
|
// per usage und wants one (the second one) back.
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
FileLockEntry::delete_tasks_by_imports(rt.store(), stdin.lock()).map_err_trace().ok();
|
rt.store().delete_tasks_by_imports(stdin.lock()).map_err_trace().ok();
|
||||||
} else {
|
} else {
|
||||||
// Should not be possible, as one argument is required via
|
// Should not be possible, as one argument is required via
|
||||||
// ArgGroup
|
// ArgGroup
|
||||||
|
@ -94,7 +92,7 @@ fn list(rt: &Runtime) {
|
||||||
is_match!(e.kind(), &::toml_query::error::ErrorKind::IdentifierNotFoundInDocument(_))
|
is_match!(e.kind(), &::toml_query::error::ErrorKind::IdentifierNotFoundInDocument(_))
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = FileLockEntry::all_tasks(rt.store()) // get all tasks
|
let res = rt.store().all_tasks() // get all tasks
|
||||||
.map(|iter| { // and if this succeeded
|
.map(|iter| { // and if this succeeded
|
||||||
// filter out the ones were we can read the uuid
|
// filter out the ones were we can read the uuid
|
||||||
let uuids : Vec<_> = iter.filter_map(|storeid| {
|
let uuids : Vec<_> = iter.filter_map(|storeid| {
|
||||||
|
|
Loading…
Reference in a new issue