Merge pull request #4 from race604/lower-rate-when-non-millis

lower tick rate when non-millis
This commit is contained in:
Jimmy 2022-08-03 19:21:00 +08:00 committed by GitHub
commit 684384c3ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -31,7 +31,7 @@ pub(crate) enum Mode {
duration: Duration,
/// Hide milliseconds
#[clap(long = "no-millis", takes_value = false)]
#[clap(long = "no-millis", short = 'M', takes_value = false)]
no_millis: bool,
},
/// The stopwatch mode displays the elapsed time since it was started.

View file

@ -60,10 +60,10 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut terminal = Terminal::new(backend)?;
// create app and run it
let low_rate = if let Some(Mode::Clock { millis, .. }) = app.mode {
!millis
} else {
false
let low_rate = match app.mode {
Some(Mode::Clock { millis, .. }) => !millis,
Some(Mode::Timer { no_millis, .. }) => no_millis,
_ => false,
};
let tick_rate = Duration::from_millis(if low_rate { 200 } else { 20 });
let res = run_app(&mut terminal, &mut app, tick_rate);