From 8a58c5a60466d9b2f3d1d2676c98bfcfbf471eab Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Mon, 15 Aug 2022 16:53:05 +1000 Subject: [PATCH] Add option to start the timer paused --- src/app.rs | 6 ++++++ src/app/modes/timer.rs | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index a625b16..100c16b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -38,6 +38,10 @@ pub(crate) enum Mode { #[clap(long = "no-millis", short = 'M', takes_value = false)] no_millis: bool, + /// Start the timer paused + #[clap(long = "paused", short = 'P', takes_value = false)] + paused: bool, + /// Command to run when the timer ends #[clap(long, short, multiple = true, allow_hyphen_values = true)] execute: Vec, @@ -110,6 +114,7 @@ impl App { Mode::Timer { duration, no_millis, + paused, execute, } => { let format = if *no_millis { @@ -122,6 +127,7 @@ impl App { self.size, style, format, + *paused, execute.to_owned(), )); } diff --git a/src/app/modes/timer.rs b/src/app/modes/timer.rs index b2a8f08..0c59dca 100644 --- a/src/app/modes/timer.rs +++ b/src/app/modes/timer.rs @@ -24,6 +24,7 @@ impl Timer { size: u16, style: Style, format: DurationFormat, + paused: bool, execute: Vec, ) -> Self { Self { @@ -32,7 +33,7 @@ impl Timer { execute, style, format, - ended_at: Some(Local::now() + duration), + ended_at: (!paused).then(|| Local::now() + duration), execute_result: RefCell::new(None), } }