diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-02-06 01:38:26 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-02-09 01:03:32 +0100 |
commit | 340dab18f031092a1c505da11bb8e154eac6f28f (patch) | |
tree | c333fca4394419d509337ea3fb0aac0598aae94c | |
parent | afe275692eae6bc64e16e52d58457c7ea12febc0 (diff) |
Fix: 'start-time' cannot be None
The UI is configured to require the 'start-time' parameter, so we do not
need to check for None here.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/domain/imag-timetrack/src/start.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/bin/domain/imag-timetrack/src/start.rs b/bin/domain/imag-timetrack/src/start.rs index 313c8947..ff440233 100644 --- a/bin/domain/imag-timetrack/src/start.rs +++ b/bin/domain/imag-timetrack/src/start.rs @@ -32,15 +32,19 @@ 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") { - None | Some("now") => ::chrono::offset::Local::now().naive_local(), - Some(ndt) => match NaiveDateTime::from_str(ndt).map_err(Error::from) { - Ok(ndt) => ndt, - Err(e) => { - trace_error(&e); - error!("Cannot continue, not having start time"); - return 1 - }, + let start = { + let startstr = cmd.value_of("start-time").unwrap(); // safe by clap + if startstr == "now" { + ::chrono::offset::Local::now().naive_local() + } else { + match NaiveDateTime::from_str(startstr).map_err(Error::from) { + Ok(ndt) => ndt, + Err(e) => { + trace_error(&e); + error!("Cannot continue, not having start time"); + return 1 + }, + } } }; |