From 0545b6d3367034b17c44ed6b7e50e46a62a6938e Mon Sep 17 00:00:00 2001 From: Yase Date: Tue, 7 Jun 2016 23:45:49 +0200 Subject: [PATCH] ui.rs needed a multiple(true) main.rs - now we get the string argument of exec --command --- imag-todo/src/main.rs | 33 ++++++++++++++++++++++++--------- imag-todo/src/ui.rs | 8 +++++--- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index bef9f7a9..4ee5a240 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -10,10 +10,16 @@ extern crate libimagstore; extern crate libimagutil; use std::process::exit; +use std::process::{Command, Stdio}; +use std::io::prelude::*; +use std::io::BufReader; +use std::fs::File; use libimagrt::runtime::Runtime; use libimagstore::store::FileLockEntry; use libimagutil::trace::trace_error; +use std::error::Error; +use std::env; mod ui; @@ -24,6 +30,7 @@ fn main() { 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() { @@ -35,6 +42,8 @@ fn main() { } }; + + let scmd = rt.cli().subcommand_name(); match scmd { Some("tw-hook") => { @@ -61,17 +70,23 @@ fn main() { } }, Some("exec") => { - let subcmd = rt.cli().subcommand_matches("exec").unwrap(); - let itr = subcmd.values_of_os("add").unwrap(); - if subcmd.is_present("command") { - let string = subcmd.value_of("command").unwrap(); - println!("{:?}", string); - else { - panic!("Reached unreachable Code"); - } + let subcmd = rt.cli().subcommand_matches("exec").unwrap(); + let mut string = String::from(""); + //let args: Vec<_> = env::args().collect(); + //println!("{:?}", args); + if let Some(execString) = subcmd.values_of("command") { + for e in execString { + string.push_str(e); + string.push_str(" "); + } + //NOW SEND "string" to taskwarrior + + } else { + println!("false"); + } }, _ => println!("Nothing implemented yet"), } - } + } diff --git a/imag-todo/src/ui.rs b/imag-todo/src/ui.rs index cc675f44..d1707298 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") @@ -35,8 +35,10 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .long("command") .short("c") .takes_value(true) + .multiple(true) .required(true) .help("Args written in the string will be send directly to taskwarrior")) - ) -} + ) + +}