diff options
author | mario <mario-krehl@gmx.de> | 2016-06-28 23:05:05 +0200 |
---|---|---|
committer | mario <mario-krehl@gmx.de> | 2016-06-28 23:05:05 +0200 |
commit | 72e85399ff4d8243f37cb1c52b907e8e61dc287e (patch) | |
tree | 7a86456c3cf6c23bb70138f4de6a696497e8a91b /imag-todo | |
parent | aa75b5ad9d41affe773d69caa8e64cc5116c0b77 (diff) |
implemented list-featureo
Diffstat (limited to 'imag-todo')
-rw-r--r-- | imag-todo/src/main.rs | 108 |
1 files changed, 83 insertions, 25 deletions
diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index b756bb31..6b463000 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -72,7 +72,7 @@ fn main() { } } else if subcmd.is_present("delete") { - println!("To be implemented"); + unimplemented!(); // // Functionality to delete Entry in the store // @@ -80,33 +80,91 @@ fn main() { else { // Should not be possible, as one argument is required via // ArgGroup - panic!("Reached unreachable Code"); + unreachable!(); } }, Some("exec") => { - let subcmd = rt.cli().subcommand_matches("exec").unwrap(); - let mut args = Vec::new(); - if let Some(exec_string) = subcmd.values_of("command") { - for e in exec_string { - args.push(e); - } - let tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| { - panic!("failed to execute taskwarrior: {}", e); - }); + let subcmd = rt.cli().subcommand_matches("exec").unwrap(); + let mut args = Vec::new(); + if let Some(exec_string) = subcmd.values_of("command") { + for e in exec_string { + args.push(e); + } + let tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| { + panic!("failed to execute taskwarrior: {}", e); + }); - let output = tw_process.wait_with_output().unwrap_or_else(|e| { - panic!("failed to unwrap output: {}", e); - }); - let outstring = String::from_utf8(output.stdout).unwrap_or_else(|e| { - panic!("failed to ececute: {}", e); - }); - println!("{}", outstring); - } else { - panic!("faild to execute: You need to exec --command"); - } - }, - _ => panic!("Reached unreachable Code"), + let output = tw_process.wait_with_output().unwrap_or_else(|e| { + panic!("failed to unwrap output: {}", e); + }); + let outstring = String::from_utf8(output.stdout).unwrap_or_else(|e| { + panic!("failed to ececute: {}", e); + }); + println!("{}", outstring); + } else { + panic!("faild to execute: You need to exec --command"); + } } - -} + Some("list") => { + let subcmd = rt.cli().subcommand_matches("list").unwrap(); + let mut args = Vec::new(); + let verbose = subcmd.is_present("verbose"); + let iter = match libimagtodo::read::get_todo_iterator(rt.store()) { + //let iter = match rt.store().retrieve_for_module("todo/taskwarrior") { + Err(e) => { + error!("{}", e); + return; + } + Ok(val) => val, + }; + for task in iter { + match task { + Ok(val) => { + //let val = libimagtodo::task::Task::new(fle); + //println!("{:#?}", val.flentry); + let uuid = match val.flentry.get_header().read("todo.uuid") { + Ok(Some(u)) => u, + Ok(None) => continue, + Err(e) => { + error!("{}", e); + continue; + } + }; + if verbose { + args.clear(); + args.push(format!("uuid:{}", uuid)); + args.push(format!("{}", "information")); + let tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn() + .unwrap_or_else(|e| { + error!("{}", e); + panic!("failed"); + }); + let output = tw_process.wait_with_output().unwrap_or_else(|e| { + panic!("failed to unwrap output: {}", e); + }); + let outstring = String::from_utf8(output.stdout).unwrap_or_else(|e| { + panic!("failed to ececute: {}", e); + }); + println!("{}", outstring); + } + else { + println!("{}", match uuid { + toml::Value::String(s) => s, + _ => { + error!("Unexpected type for todo.uuid: {}", uuid); + continue; + }, + }); + } + } + Err(e) => { + error!("{}", e); + continue; + } + } + } + } + _ => unimplemented!(), + } + } |