From 284f12e8cb2503915ab9040d674f9c3bb72ec82c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 13 Jan 2018 14:31:24 +0100 Subject: [PATCH 1/2] Refactor: Split actual list implementation from argument processing --- bin/domain/imag-timetrack/src/list.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/domain/imag-timetrack/src/list.rs b/bin/domain/imag-timetrack/src/list.rs index 109a7ae6..88c61504 100644 --- a/bin/domain/imag-timetrack/src/list.rs +++ b/bin/domain/imag-timetrack/src/list.rs @@ -19,6 +19,7 @@ use std::str::FromStr; +use chrono::NaiveDateTime; use filters::filter::Filter; use libimagerror::trace::trace_error; @@ -53,6 +54,16 @@ pub fn list(rt: &Runtime) -> i32 { let list_not_ended = cmd.is_present("list-not-ended"); + list_impl(rt, start, end, list_not_ended) +} + +pub fn list_impl(rt: &Runtime, + start: Option, + end: Option, + list_not_ended: bool) + -> i32 +{ + let start_time_filter = |timetracking: &FileLockEntry| { start.map(|s| match timetracking.get_start_datetime() { Ok(Some(dt)) => dt >= s, From 5beadbbf5b03c3e5a48a54f592ab067605a8d038 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 13 Jan 2018 14:36:13 +0100 Subject: [PATCH 2/2] Call default command if no command is passed --- bin/domain/imag-timetrack/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/domain/imag-timetrack/src/main.rs b/bin/domain/imag-timetrack/src/main.rs index cdfd979d..55a8d01f 100644 --- a/bin/domain/imag-timetrack/src/main.rs +++ b/bin/domain/imag-timetrack/src/main.rs @@ -45,7 +45,7 @@ mod year; use cont::cont; use day::day; -use list::list; +use list::{list, list_impl}; use month::month; use start::start; use stop::stop; @@ -81,8 +81,9 @@ fn main() { }, } } else { - error!("No command"); - 1 + let start = ::chrono::offset::Local::today().naive_local().and_hms(0, 0, 0); + let end = ::chrono::offset::Local::today().naive_local().and_hms(23, 59, 59); + list_impl(&rt, Some(start), Some(end), false) }; ::std::process::exit(retval);