Merge pull request #1218 from matthiasbeyer/imag-timetrack/default-command

imag-timetrack: default command
This commit is contained in:
Matthias Beyer 2018-01-15 13:01:25 +01:00 committed by GitHub
commit 2b0dfec457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -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<NaiveDateTime>,
end: Option<NaiveDateTime>,
list_not_ended: bool)
-> i32
{
let start_time_filter = |timetracking: &FileLockEntry| {
start.map(|s| match timetracking.get_start_datetime() {
Ok(Some(dt)) => dt >= s,

View file

@ -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);