generated from PlexSheep/rs-base
support millis option for countdown timer
This commit is contained in:
parent
aa03b69ef6
commit
75e7de904d
2 changed files with 11 additions and 1 deletions
11
src/app.rs
11
src/app.rs
|
@ -72,6 +72,10 @@ pub(crate) enum Mode {
|
||||||
/// Reverse the countdown, a.k.a. countup
|
/// Reverse the countdown, a.k.a. countup
|
||||||
#[clap(long, short, takes_value = false)]
|
#[clap(long, short, takes_value = false)]
|
||||||
reverse: bool,
|
reverse: bool,
|
||||||
|
|
||||||
|
/// Show milliseconds
|
||||||
|
#[clap(short, long, takes_value = false)]
|
||||||
|
millis: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +170,7 @@ impl App {
|
||||||
title,
|
title,
|
||||||
continue_on_zero,
|
continue_on_zero,
|
||||||
reverse,
|
reverse,
|
||||||
|
millis,
|
||||||
} => {
|
} => {
|
||||||
self.countdown = Some(Countdown {
|
self.countdown = Some(Countdown {
|
||||||
size: self.size,
|
size: self.size,
|
||||||
|
@ -174,7 +179,11 @@ impl App {
|
||||||
title: title.to_owned(),
|
title: title.to_owned(),
|
||||||
continue_on_zero: *continue_on_zero,
|
continue_on_zero: *continue_on_zero,
|
||||||
reverse: *reverse,
|
reverse: *reverse,
|
||||||
format: DurationFormat::HourMinSec,
|
format: if *millis {
|
||||||
|
DurationFormat::HourMinSecDeci
|
||||||
|
} else {
|
||||||
|
DurationFormat::HourMinSec
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
millis, no_seconds, ..
|
millis, no_seconds, ..
|
||||||
}) => !millis || no_seconds,
|
}) => !millis || no_seconds,
|
||||||
Some(Mode::Timer { no_millis, .. }) => no_millis,
|
Some(Mode::Timer { no_millis, .. }) => no_millis,
|
||||||
|
Some(Mode::Countdown { millis, .. }) => !millis,
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
let tick_rate = Duration::from_millis(if low_rate { 200 } else { 20 });
|
let tick_rate = Duration::from_millis(if low_rate { 200 } else { 20 });
|
||||||
|
|
Reference in a new issue