Refactor: Split actual list implementation from argument processing

This commit is contained in:
Matthias Beyer 2018-01-13 14:31:24 +01:00
parent 184a6882b7
commit 284f12e8cb

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,