From 44af71c01cb7693d7aee6f83813ff856b44bd552 Mon Sep 17 00:00:00 2001 From: Jens Krause <47693+sectore@users.noreply.github.com> Date: Mon, 12 May 2025 12:14:27 +0200 Subject: [PATCH] (args) set `content` by given duration (#81) --- CHANGELOG.md | 8 +++++++- src/app.rs | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0895e0f..8fd97b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ # Changelog +## [Unreleased] + +### Features + +- (args) set `content` by given duration [#81](https://github.com/sectore/tick-tock-tui/pull/81) + ## v1.3.0 - 2025-05-06 -### Features +### - (pomodoro) Count WORK rounds [#75](https://github.com/sectore/timr-tui/pull/75), [6b068bb](https://github.com/sectore/timr-tui/commit/6b068bbd094d9ec1a36b47598fadfc71296d9590) - (pomodoro/countdown) Change initial value [#79](https://github.com/sectore/timr-tui/pull/79), [aae5c38](https://github.com/sectore/timr-tui/commit/aae5c38cd6a666d5ba418b12fb67879a2146b9a2) diff --git a/src/app.rs b/src/app.rs index ee6472a..fa5f3e5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -92,7 +92,22 @@ impl From for App { notification: args.notification.unwrap_or(stg.notification), blink: args.blink.unwrap_or(stg.blink), app_time_format: stg.app_time_format, - content: args.mode.unwrap_or(stg.content), + // Check args to set a possible mode to start with. + content: match args.mode { + Some(mode) => mode, + // check other args (especially durations) + None => { + if args.work.is_some() || args.pause.is_some() { + Content::Pomodoro + } else if args.countdown.is_some() { + Content::Countdown + } + // in other case just use latest stored state + else { + stg.content + } + } + }, style: args.style.unwrap_or(stg.style), pomodoro_mode: stg.pomodoro_mode, pomodoro_round: stg.pomodoro_count,