diff --git a/bin/domain/imag-calendar/src/filters.rs b/bin/domain/imag-calendar/src/filters.rs index 063936b9..20743671 100644 --- a/bin/domain/imag-calendar/src/filters.rs +++ b/bin/domain/imag-calendar/src/filters.rs @@ -61,6 +61,10 @@ pub fn event_is_before<'a>(event: &Event<'a>, before_spec: &NaiveDateTime) -> bo } } +pub fn event_is_after<'a>(event: &Event<'a>, after_spec: &NaiveDateTime) -> bool { + !event_is_before(event, after_spec) +} + fn try_to_parse_datetime(s: &str) -> Result { const FORMATS : &[&'static str] = &[ "%Y%m%dT%H%M%S", diff --git a/bin/domain/imag-calendar/src/main.rs b/bin/domain/imag-calendar/src/main.rs index 3d8f74d0..21258d17 100644 --- a/bin/domain/imag-calendar/src/main.rs +++ b/bin/domain/imag-calendar/src/main.rs @@ -174,6 +174,7 @@ fn list(rt: &Runtime) { let do_filter_past = !scmd.is_present("list-past"); let do_filter_before = scmd.value_of("list-before"); + let do_filter_after = scmd.value_of("list-after"); let ref_config = rt.config() .ok_or_else(|| format_err!("No configuration, cannot continue!")) @@ -205,7 +206,14 @@ fn list(rt: &Runtime) { filters::event_is_before(event, spec) }).unwrap_or(true); - allow_all_past_events(e) && allow_events_before_date(e) + + let do_filter_after = do_filter_after.map(|spec| kairos_parse(spec).map_err_trace_exit_unwrap()); + + let allow_events_after_date = |event| do_filter_after.as_ref().map(|spec| { + filters::event_is_after(event, spec) + }).unwrap_or(true); + + allow_all_past_events(e) && allow_events_before_date(e) && allow_events_after_date(e) }; let mut listed_events = 0; diff --git a/bin/domain/imag-calendar/src/ui.rs b/bin/domain/imag-calendar/src/ui.rs index 4c1c1898..76a565ec 100644 --- a/bin/domain/imag-calendar/src/ui.rs +++ b/bin/domain/imag-calendar/src/ui.rs @@ -81,6 +81,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .required(false) .multiple(false) .help("List events which are dated before certain date")) + + .arg(Arg::with_name("list-after") + .long("after") + .takes_value(true) + .required(false) + .multiple(false) + .help("List events which are dated after certain date")) ) }