diff --git a/src/app.rs b/src/app.rs index 490de75..d56accd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -82,11 +82,14 @@ impl From<(Args, AppStorage)> for AppArgs { style: args.style.unwrap_or(stg.style), pomodoro_mode: stg.pomodoro_mode, initial_value_work: args.work.unwrap_or(stg.inital_value_work), - current_value_work: stg.current_value_work, - initial_value_pause: args.pause, - current_value_pause: stg.current_value_pause, - initial_value_countdown: args.countdown, - current_value_countdown: stg.current_value_countdown, + // invalidate `current_value_work` if an initial value is set via args + current_value_work: args.work.unwrap_or(stg.current_value_work), + initial_value_pause: args.pause.unwrap_or(stg.inital_value_pause), + // invalidate `current_value_pause` if an initial value is set via args + current_value_pause: args.pause.unwrap_or(stg.current_value_pause), + initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown), + // invalidate `current_value_countdown` if an initial value is set via args + current_value_countdown: args.countdown.unwrap_or(stg.current_value_countdown), current_value_timer: stg.current_value_timer, } } diff --git a/src/args.rs b/src/args.rs index 8924274..aa3bc7e 100644 --- a/src/args.rs +++ b/src/args.rs @@ -10,10 +10,9 @@ use crate::{app::Content, widgets::clock::Style}; #[derive(Parser)] pub struct Args { #[arg(long, short, value_parser = parse_duration, - default_value="10:00" /* 10min */, help = "Countdown time to start from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss'" )] - pub countdown: Duration, + pub countdown: Option, #[arg(long, short, value_parser = parse_duration, help = "Work time to count down from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss'" @@ -21,10 +20,9 @@ pub struct Args { pub work: Option, #[arg(long, short, value_parser = parse_duration, - default_value="5:00" /* 5min */, help = "Pause time to count down from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss'" )] - pub pause: Duration, + pub pause: Option, #[arg(long, short = 'd', help = "Whether to show deciseconds or not.")] pub decis: bool, diff --git a/src/main.rs b/src/main.rs index 68c70bc..b1ddbc0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ mod terminal; mod utils; mod widgets; -use app::App; +use app::{App, AppArgs}; use args::Args; use clap::Parser; use color_eyre::Result; @@ -43,7 +43,7 @@ async fn main() -> Result<()> { }; // merge `Args` and `AppStorage`. - let app_args = (args, stg).into(); + let app_args: AppArgs = (args, stg).into(); let app_storage = App::new(app_args).run(terminal, events).await?.to_storage(); // store app state persistantly storage.save(app_storage)?;