diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index 38e5ef1d..b756bb31 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -18,10 +18,8 @@ use std::process::{Command, Stdio}; use std::io::stdin; use task_hookrs::import::import; -use task_hookrs::task::Task as TTask; use libimagrt::runtime::Runtime; -use libimagtodo::task::Task; use libimagtodo::task::IntoTask; use libimagutil::trace::trace_error; @@ -53,7 +51,7 @@ fn main() { Some("tw-hook") => { let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap(); if subcmd.is_present("add") { - if let Ok(ttasks) = task_hookrs::import::import(stdin()) { + if let Ok(ttasks) = import(stdin()) { for ttask in ttasks { println!("{}", match serde_json::ser::to_string(&ttask) { Ok(val) => val, @@ -62,7 +60,7 @@ fn main() { return; } }); - let task = match ttask.into_filelockentry(rt.store()) { + match ttask.into_filelockentry(rt.store()) { Ok(val) => val, Err(e) => { trace_error(&e); @@ -92,7 +90,7 @@ fn main() { for e in exec_string { args.push(e); } - let mut tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| { + let tw_process = Command::new("task").stdin(Stdio::null()).args(&args).spawn().unwrap_or_else(|e| { panic!("failed to execute taskwarrior: {}", e); }); diff --git a/imag-todo/src/ui.rs b/imag-todo/src/ui.rs index a9ec0048..ae2adc07 100644 --- a/imag-todo/src/ui.rs +++ b/imag-todo/src/ui.rs @@ -1,7 +1,7 @@ use clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { - app + app .subcommand(SubCommand::with_name("tw-hook") .about("For use in a taskwarrior hook") .version("0.1") @@ -22,65 +22,78 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .group(ArgGroup::with_name("taskwarrior hooks") .args(&[ "add", - "delete", - ]) + "delete", + ]) .required(true)) ) - .subcommand(SubCommand::with_name("exec") - .about("Send a command to taskwarrior") - .version("0.1") + .subcommand(SubCommand::with_name("exec") + .about("Send a command to taskwarrior") + .version("0.1") - .arg(Arg::with_name("command") - .long("command") - .short("c") - .takes_value(true) - .multiple(true) - .required(true) - .help("Args written in the string will be send directly to taskwarrior")) + .arg(Arg::with_name("command") + .long("command") + .short("c") + .takes_value(true) + .multiple(true) + .required(true) + .help("Args written in the string will be send directly to taskwarrior") + ) + ) - ) + .subcommand(SubCommand::with_name("add") + .about("create a task") + .version("0.1") - .subcommand(SubCommand::with_name("add") - .about("create a task") - .version("0.1") + .arg(Arg::with_name("description") + .long("description") + .short("d") + .takes_value(true) + .required(true) + .help("Name/Description of the new task") + ) - .arg(Arg::with_name("description") - .long("description") - .short("d") - .takes_value(true) - .required(true) - .help("Name/Description of the new task") - ) + .arg(Arg::with_name("priority") + .long("priority") + .short("p") + .takes_value(true) + .required(false) + .help("One of l, m, h for low, medium and high priority") + ) - .arg(Arg::with_name("priority") - .long("priority") - .short("p") - .takes_value(true) - .required(false) - .help("One of l, m, h for low, medium and high priority") - ) + .arg(Arg::with_name("project") + .long("project") + .takes_value(true) + .required(false) + .help("Name of the project the task is related to") + ) - .arg(Arg::with_name("project") - .long("project") - .takes_value(true) - .required(false) - .help("Name of the project the task is related to") - ) + .arg(Arg::with_name("due") + .long("due") + .takes_value(true) + .required(false) + .help("Due date of the new task") + ) - .arg(Arg::with_name("due") - .long("due") - .takes_value(true) - .required(false) - .help("Due date of the new task") - ) + .arg(Arg::with_name("frequency") + .long("frequency") + .short("f") + .takes_value(true) + .required(false) + .help("Frequency of the recurrence of a task") + ) + ) - .arg(Arg::with_name("frequency") - .long("frequency") - .short("f") - .takes_value(true) - .required(false) - .help("Frequency of the recurrence of a task") - ) - ) + .subcommand(SubCommand::with_name("list") + .about("List all tasks") + .version("0.1") + + .arg(Arg::with_name("verbose") + .long("verbose") + .short("v") + .takes_value(false) + .required(false) + .help("Asks taskwarrior for all the details") + ) + ) }