From 2e49507453ec5f5ec1052c79ad23d1c77babb67c Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Mon, 17 Dec 2018 13:29:47 +0100 Subject: Add period to the config file --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index a65ace0..64fdf05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,19 +15,23 @@ use almanac::Event; use almanac::Config; fn main() { + let conf = Config::parse().unwrap_or(Config::new()); let mut args = env::args().skip(1); let period_arg = match args.next() { Some(arg) => arg, None => { - println!("Usage: almanac day|week|month [ical ...]"); - return; + if conf.period.is_empty() { + println!("Usage: almanac day|week|month [ical ...]"); + return; + } else { + conf.period + } } }; let (first, last) = period(&period_arg); let mut calendars: Vec<_> = args.map(|arg| ics_calendar(&arg)).collect(); if calendars.is_empty() { - let conf = Config::parse().unwrap(); for cal in &conf.cals { calendars.push(ics_calendar(cal)) } -- cgit v1.2.3