diff --git a/src/main.rs b/src/main.rs index 53bf7af..9172ff3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,40 @@ +use std::time::Duration; + +use clap::Parser; use egui::Vec2; -use katabastird::timer::Timer; +use katabastird::timer::{CountDirection, Timer}; + +#[derive(Debug, Parser)] +#[clap(author, version, about)] +struct Cli { + /// Hours to count down. + #[clap(long, default_value_t = 0)] + hours: u64, + + /// Minutes to count down. + #[clap(long, short, default_value_t = 0)] + minutes: u64, + + /// Seconds to count down. + #[clap(long, short, default_value_t = 0)] + seconds: u64, + + /// Audio file to play at the end of the countdown. + #[clap(long, short)] + alarm: Option, + + /// Begin countdown immediately. + #[clap(long = "immediate", long = "running", short = 'i', short = 'r')] + running: bool, + + /// Count up from zero, actually. + #[clap(long, short = 'u')] + count_up: bool, + + /// Use the Predator font. + #[clap(long, short)] + predator: bool, +} fn main() { let options = eframe::NativeOptions { @@ -8,9 +43,20 @@ fn main() { ..Default::default() }; + let cli = Cli::parse(); + + let seconds = cli.hours * 3600 + cli.minutes * 60 + cli.seconds; + let duration = Duration::from_secs(seconds.max(30)); + + let direction = if cli.count_up { + CountDirection::Up + } else { + CountDirection::Down + }; + eframe::run_native( "katabastird", options, - Box::new(|_cc| Box::new(Timer::default())), + Box::new(move |_cc| Box::new(Timer::new(duration, direction, !cli.running))), ); }