diff --git a/imag-timetrack/src/start.rs b/imag-timetrack/src/start.rs index 13b1f3e8..8518f566 100644 --- a/imag-timetrack/src/start.rs +++ b/imag-timetrack/src/start.rs @@ -29,14 +29,16 @@ pub fn start(rt: &Runtime) -> i32 { let (_, cmd) = rt.cli().subcommand(); let cmd = cmd.unwrap(); // checked in main() - let start = match cmd.value_of("start-time").map(::chrono::naive::NaiveDateTime::from_str) { - None => ::chrono::offset::Local::now().naive_local(), - Some(Ok(ndt)) => ndt, - Some(Err(e)) => { - trace_error(&e); - error!("Cannot continue, not having start time"); - return 1 - }, + let start = match cmd.value_of("start-time") { + None | Some("now") => ::chrono::offset::Local::now().naive_local(), + Some(ndt) => match ::chrono::naive::NaiveDateTime::from_str(ndt) { + Ok(ndt) => ndt, + Err(e) => { + trace_error(&e); + error!("Cannot continue, not having start time"); + return 1 + }, + } }; cmd.values_of("tags") diff --git a/imag-timetrack/src/stop.rs b/imag-timetrack/src/stop.rs index c1c5e682..29b03a02 100644 --- a/imag-timetrack/src/stop.rs +++ b/imag-timetrack/src/stop.rs @@ -37,16 +37,19 @@ pub fn stop(rt: &Runtime) -> i32 { let (_, cmd) = rt.cli().subcommand(); let cmd = cmd.unwrap(); // checked in main() - let stop_time = match cmd.value_of("stop-time").map(::chrono::naive::NaiveDateTime::from_str) { - None => ::chrono::offset::Local::now().naive_local(), - Some(Ok(ndt)) => ndt, - Some(Err(e)) => { - trace_error(&e); - error!("Cannot continue, not having stop time"); - return 1 - }, + let stop_time = match cmd.value_of("stop-time") { + None | Some("now") => ::chrono::offset::Local::now().naive_local(), + Some(ndt) => match ::chrono::naive::NaiveDateTime::from_str(ndt) { + Ok(ndt) => ndt, + Err(e) => { + trace_error(&e); + error!("Cannot continue, not having start time"); + return 1 + }, + } }; + // TODO: We do not yet support stopping all tags by simply calling the "stop" subcommand! let tags : Vec = cmd.values_of("tags") diff --git a/imag-timetrack/src/ui.rs b/imag-timetrack/src/ui.rs index f394057d..a27c4ced 100644 --- a/imag-timetrack/src/ui.rs +++ b/imag-timetrack/src/ui.rs @@ -25,8 +25,8 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .version("0.1") .arg(Arg::with_name("start-time") .index(1) - .required(false) - .help("Start-time when to start the timetracking")) + .required(true) + .help("Start-time when to start the timetracking (use 'now' for current time)")) .arg(Arg::with_name("tags") .index(2) .required(true) @@ -39,8 +39,8 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .version("0.1") .arg(Arg::with_name("end-time") .index(1) - .required(false) - .help("End-time when to stop the timetracking")) + .required(true) + .help("End-time when to stop the timetracking (use 'now' for current time)")) .arg(Arg::with_name("tags") .index(2) .required(true)