From 20255c86854e628756ff8b71e7be5384dcaac41f Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 18 Dec 2018 15:06:36 +0100 Subject: Take filename and pattern from command line and output matching events. Extremely primitive command line handling for now. Pass first arg as filename, second as pattern. Both must be present. Pass "*" as pattern to match all events in the input file. --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f6aec5c..d3b8872 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,11 +104,14 @@ fn match_events_by_summary() { } fn main() { - let calendars = read_icalendar_from_file("test.ics").unwrap(); + let mut args = std::env::args().skip(1); + let filename = args.next().unwrap(); + let pattern = args.next().unwrap(); + let calendars = read_icalendar_from_file(&filename).unwrap(); println!("Found {} calendard in file...", calendars.len()); for c in calendars { - for e in c.events { + for e in c.events.iter().filter(|e| match_event(&e, &pattern)) { print_event(&e); } } -- cgit v1.2.3