summaryrefslogtreecommitdiffstats
path: root/imag-todo
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-07-10 16:35:24 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-07-21 17:14:12 +0200
commitb918f4abbe095f1cba64a187824fb55bd5620700 (patch)
treec5e1f7a9b489f02823ec3830c08ac81d525030e8 /imag-todo
parent0041a648c34ddeed4d8e636ee0fb2534114b37dd (diff)
Rewrite UI with Task::import()
Diffstat (limited to 'imag-todo')
-rw-r--r--imag-todo/src/main.rs33
1 files changed, 5 insertions, 28 deletions
diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs
index cf2453c9..4bad0a26 100644
--- a/imag-todo/src/main.rs
+++ b/imag-todo/src/main.rs
@@ -47,36 +47,13 @@ fn tw_hook(rt: &Runtime) {
if subcmd.is_present("add") {
let stdin = stdin();
let mut stdin = stdin.lock();
- let mut line = String::new();
- if let Err(e) = stdin.read_line(&mut line) {
- trace_error(&e);
- exit(1);
- };
-
- if let Ok(ttask) = import_task(&line.as_str()) {
- match serde_json::ser::to_string(&ttask) {
- Ok(val) => println!("{}", val),
- Err(e) => {
- trace_error(&e);
- exit(1);
- }
+ match Task::import(rt.store(), stdin) {
+ Ok((_, uuid)) => info!("Task {} stored in imag", uuid),
+ Err(e) => {
+ trace_error(&e);
+ exit(1);
}
-
- let uuid = *ttask.uuid();
- match ttask.into_task(rt.store()) {
- Ok(val) => {
- println!("Task {} stored in imag", uuid);
- val
- },
- Err(e) => {
- trace_error(&e);
- exit(1);
- }
- };
- } else {
- error!("No usable input");
- exit(1);
}
} else if subcmd.is_present("delete") {
// The used hook is "on-modify". This hook gives two json-objects