diff --git a/src/main.rs b/src/main.rs index fa7a947..507020c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,11 @@ use anyhow::{bail, Result}; use tokio::sync::broadcast::channel; use tokio::task::JoinSet; +use message::Message; +use pid::Pid; +use pomodoro::Pomodoro; +use ui::{clear_terminal, Ui}; + #[tokio::main(flavor = "current_thread")] async fn main() -> ExitCode { match main2().await { @@ -22,25 +27,25 @@ async fn main() -> ExitCode { } async fn main2() -> Result<()> { - let pid = if let Some(pid) = pid::Pid::check_already_running() { + let pid = if let Some(pid) = Pid::check_already_running() { bail!("already running (pid {})", pid.pid) } else { - pid::Pid::create()? + Pid::create()? }; let result = run_all_tasks().await; - ui::clear_terminal()?; + clear_terminal()?; pid.remove()?; result } async fn run_all_tasks() -> Result<()> { - let (tx, rx) = channel::(10); + let (tx, rx) = channel::(10); - let timer = pomodoro::Pomodoro::new(rx); - let ui = ui::Ui::new(tx); + let timer = Pomodoro::new(rx); + let ui = Ui::new(tx); let mut tasks = JoinSet::new(); diff --git a/src/pomodoro.rs b/src/pomodoro.rs index 7954c28..47bbee0 100644 --- a/src/pomodoro.rs +++ b/src/pomodoro.rs @@ -122,8 +122,9 @@ impl Pomodoro { } fn format(dur: Duration) -> String { - let min = dur.as_secs() / 60; - let sec = dur.as_secs() % 60; + let secs = dur.as_secs(); + let min = secs / 60; + let sec = secs % 60; format!("{min}:{sec:0>2}") }