aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-12-18 15:06:36 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-12-18 15:07:58 +0100
commit20255c86854e628756ff8b71e7be5384dcaac41f (patch)
tree4534e57d51d6a5252825962070ccc29353673370
parent9545d88f026d793a74b3b26c5ec7c085311eeb61 (diff)
downloadicaltool-20255c86854e628756ff8b71e7be5384dcaac41f.tar.gz
icaltool-20255c86854e628756ff8b71e7be5384dcaac41f.tar.bz2
icaltool-20255c86854e628756ff8b71e7be5384dcaac41f.zip
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.
-rw-r--r--src/main.rs7
1 files 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);
}
}