diff --git a/src/main.rs b/src/main.rs index 67c69e2..138ed56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,48 @@ use structopt::StructOpt; +use chrono::{Local, NaiveTime}; +use std::process; +use std::process::Command; #[derive(Debug, StructOpt)] #[structopt( author, about)] struct Cli { - #[structopt(short = "k", help="output khal events")] + #[structopt(short, long, help="output khal events")] khal: bool, - #[structopt(short = "t", help="output todos")] + #[structopt(short, long, help="output todos")] todo: bool, } fn main() { let args = Cli::from_args(); - if args.khal && args.todo { - println!("khal"); + if ( !args.khal && !args.todo ) || + ( args.khal && args.todo ) + { + eprintln!("Please provide either khal or todo flag."); + Cli::clap().print_help(); + println!(); + process::exit(1); + } + + let now = Local::now().time(); + let from = now.format("%H:%M").to_string(); + + if args.khal { + let cmd = Command::new("khal") + .arg("list") + .arg("-df") + .arg("{name}") + .arg("-f") + .arg("{start-time}") + .arg("--notstarted") + .arg(&from) + .arg("23:59") + .output(); + + println!("khal output"); + } else if args.todo { + println!("todo output"); } - println!("{:?}", args); }