diff --git a/imag-todo/Cargo.toml b/imag-todo/Cargo.toml index fb21e2e6..213b2710 100644 --- a/imag-todo/Cargo.toml +++ b/imag-todo/Cargo.toml @@ -1,6 +1,22 @@ [package] +authors = ["mario "] name = "imag-todo" version = "0.1.0" -authors = ["mario "] [dependencies] +clap = "2.4.3" +glob = "0.2.11" +log = "0.3.6" +semver = "0.2.3" +toml = "0.1.28" +version = "2.0.1" + +[dependencies.libimagstore] +path = "../libimagstore" + +[dependencies.libimagrt] +path = "../libimagrt" + +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index e7a11a96..3737baa3 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -1,3 +1,67 @@ +extern crate clap; +extern crate glob; +#[macro_use] extern crate log; +extern crate semver; +extern crate toml; +#[macro_use] extern crate version; + +extern crate libimagrt; +extern crate libimagstore; +extern crate libimagutil; + +use std::process::exit; + +use libimagrt::runtime::Runtime; +use libimagstore::store::FileLockEntry; +use libimagutil::trace::trace_error; + +mod ui; + +use ui::build_ui; + fn main() { - println!("Hello, world!"); + let name = "imag-todo"; + let version = &version!()[..]; + let about = "Interface with taskwarrior"; + let ui = build_ui(Runtime::get_default_cli_builder(name, version, about)); + let rt = { + let rt = Runtime::new(ui); + if rt.is_ok() { + rt.unwrap() + } else { + println!("Could not set up Runtime"); + println!("{:?}", rt.unwrap_err()); + exit(1); + } + }; + + let scmd = rt.cli().subcommand_name(); + match scmd { + Some("tw-hook") => { + let subcmd = rt.cli().subcommand_matches("tw-hook").unwrap(); + if subcmd.is_present("add") { + println!("To be implemented"); + // + // TODO @Kevin: import function aus task_hookrs benutzen, um + // stdin auszulesen, und dann auf dem + // task_hookrs::task::Task den Trait für die + // Umwandlung aufrufen. + // + } + else if subcmd.is_present("delete") { + println!("To be implemented"); + // + // Functionality to delete Entry in the store + // + } + else { + // Should not be possible, as one argument is required via + // ArgGroup + panic!("Reached unreachable Code"); + } + }, + Some("exec") => { + }, + _ => println!("Nothing implemented yet"), + } } diff --git a/imag-todo/src/ui.rs b/imag-todo/src/ui.rs new file mode 100644 index 00000000..cc675f44 --- /dev/null +++ b/imag-todo/src/ui.rs @@ -0,0 +1,42 @@ +use clap::{Arg, App, ArgGroup, SubCommand}; + +pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { + app + .subcommand(SubCommand::with_name("tw-hook") + .about("For use in a taskwarrior hook") + .version("0.1") + + .arg(Arg::with_name("add") + .long("add") + .short("a") + .takes_value(false) + .required(false) + .help("For use in an on-add hook")) + + .arg(Arg::with_name("delete") + .long("delete") + .short("d") + .takes_value(false) + .required(false) + .help("For use in an on-delete hook")) + + .group(ArgGroup::with_name("taskwarrior hooks") + .args(&[ "add", + "delete", + ]) + .required(true)) + ) + + .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) + .required(true) + .help("Args written in the string will be send directly to taskwarrior")) + ) +} +