generated from PlexSheep/rs-base
Add option to start the timer paused
This commit is contained in:
parent
c0b4142ba0
commit
8a58c5a604
2 changed files with 8 additions and 1 deletions
|
@ -38,6 +38,10 @@ pub(crate) enum Mode {
|
||||||
#[clap(long = "no-millis", short = 'M', takes_value = false)]
|
#[clap(long = "no-millis", short = 'M', takes_value = false)]
|
||||||
no_millis: bool,
|
no_millis: bool,
|
||||||
|
|
||||||
|
/// Start the timer paused
|
||||||
|
#[clap(long = "paused", short = 'P', takes_value = false)]
|
||||||
|
paused: bool,
|
||||||
|
|
||||||
/// Command to run when the timer ends
|
/// Command to run when the timer ends
|
||||||
#[clap(long, short, multiple = true, allow_hyphen_values = true)]
|
#[clap(long, short, multiple = true, allow_hyphen_values = true)]
|
||||||
execute: Vec<String>,
|
execute: Vec<String>,
|
||||||
|
@ -110,6 +114,7 @@ impl App {
|
||||||
Mode::Timer {
|
Mode::Timer {
|
||||||
duration,
|
duration,
|
||||||
no_millis,
|
no_millis,
|
||||||
|
paused,
|
||||||
execute,
|
execute,
|
||||||
} => {
|
} => {
|
||||||
let format = if *no_millis {
|
let format = if *no_millis {
|
||||||
|
@ -122,6 +127,7 @@ impl App {
|
||||||
self.size,
|
self.size,
|
||||||
style,
|
style,
|
||||||
format,
|
format,
|
||||||
|
*paused,
|
||||||
execute.to_owned(),
|
execute.to_owned(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ impl Timer {
|
||||||
size: u16,
|
size: u16,
|
||||||
style: Style,
|
style: Style,
|
||||||
format: DurationFormat,
|
format: DurationFormat,
|
||||||
|
paused: bool,
|
||||||
execute: Vec<String>,
|
execute: Vec<String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -32,7 +33,7 @@ impl Timer {
|
||||||
execute,
|
execute,
|
||||||
style,
|
style,
|
||||||
format,
|
format,
|
||||||
ended_at: Some(Local::now() + duration),
|
ended_at: (!paused).then(|| Local::now() + duration),
|
||||||
execute_result: RefCell::new(None),
|
execute_result: RefCell::new(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue