diff options
author | mario <mario-krehl@gmx.de> | 2016-06-30 18:25:57 +0200 |
---|---|---|
committer | mario <mario-krehl@gmx.de> | 2016-06-30 18:25:57 +0200 |
commit | 8225f1a93e43ee3a66860ced8676adc85c1df78a (patch) | |
tree | bea3b39f6f8077ffa5719922386da7ce9d580018 /imag-todo | |
parent | d0d9eac61cfaf2110ccb5522769fb02fe2b50311 (diff) |
add-hook working
Diffstat (limited to 'imag-todo')
-rw-r--r-- | imag-todo/src/main.rs | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index 29a4925f..6d4cc70e 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -18,7 +18,7 @@ use std::process::{Command, Stdio}; use std::io::stdin; use std::io::BufRead; -use task_hookrs::import::import; +use task_hookrs::import::{import, import_task, import_tasks}; use libimagrt::runtime::Runtime; use libimagtodo::task::IntoTask; @@ -52,24 +52,32 @@ fn main() { Some("tw-hook") => { let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap(); if subcmd.is_present("add") { - if let Ok(ttasks) = import(stdin()) { - for ttask in ttasks { - println!("{}", match serde_json::ser::to_string(&ttask) { - Ok(val) => val, - Err(e) => { - error!("{}", e); - return; - } - }); - match ttask.into_filelockentry(rt.store()) { - Ok(val) => val, - Err(e) => { - trace_error(&e); - error!("{}", e); - return; - } - }; + let stdin = stdin(); + let mut stdin = stdin.lock(); + let mut line = String::new(); + match stdin.read_line(&mut line) { + Ok(_) => { } + Err(e) => { + error!("{}", e); + return; } + }; + if let Ok(ttask) = import_task(&line.as_str()) { + print!("{}", match serde_json::ser::to_string(&ttask) { + Ok(val) => val, + Err(e) => { + error!("{}", e); + return; + } + }); + match ttask.into_filelockentry(rt.store()) { + Ok(val) => val, + Err(e) => { + trace_error(&e); + error!("{}", e); + return; + } + }; } else { error!("No usable input"); @@ -118,8 +126,8 @@ fn main() { } _ => { } - } - } + } // end match ttask.status() + } // end for } else { error!("No usable input"); @@ -212,10 +220,10 @@ fn main() { error!("{}", e); continue; } - } - } - } - _ => unimplemented!(), + } // end match task + } // end for } - } + _ => unimplemented!(), + } // end match scmd +} // end main |