(cli)! Remove --countdown-target argument (#121)

Reverts #112.

For targeting a date (past/future) a new `event` feature will be
introduced (soon).
This commit is contained in:
Jens Krause 2025-10-08 18:03:06 +02:00 committed by GitHub
parent f79813ac6b
commit 99032834be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 28 additions and 56 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## [unreleased]
### Breaking change
- (cli)! Remove `--countdown-target` argument [#121](https://github.com/sectore/timr-tui/pull/121)
## v1.5.0 - 2025-10-03 ## v1.5.0 - 2025-10-03
### Features ### Features

View File

@ -87,34 +87,19 @@ timr-tui --help
Usage: timr-tui [OPTIONS] Usage: timr-tui [OPTIONS]
Options: Options:
-c, --countdown <COUNTDOWN> -c, --countdown <COUNTDOWN> Countdown time to start from. Formats: 'Yy Dd hh:mm:ss', 'Dd hh:mm:ss', 'Yy mm:ss', 'Dd mm:ss', 'Yy ss', 'Dd ss', 'hh:mm:ss', 'mm:ss', 'ss'. Examples: '1y 5d 10:30:00', '2d 4:00', '1d 10', '5:03'.
Countdown time to start from. Formats: 'Yy Dd hh:mm:ss', 'Dd hh:mm:ss', 'Yy mm:ss', 'Dd mm:ss', 'Yy ss', 'Dd ss', 'hh:mm:ss', 'mm:ss', 'ss'. Examples: '1y 5d 10:30:00', '2d 4:00', '1d 10', '5:03'. -w, --work <WORK> Work time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss'
--countdown-target <COUNTDOWN_TARGET> -p, --pause <PAUSE> Pause time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss'
Countdown targeting a specific time in the future or past. Formats: 'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:mm', 'hh:mm:ss', 'hh:mm', 'mm' [aliases: --ct] -d, --decis Show deciseconds.
-w, --work <WORK> -m, --mode <MODE> Mode to start with. [possible values: countdown, timer, pomodoro, event, localtime]
Work time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss' -s, --style <STYLE> Style to display time with. [possible values: full, light, medium, dark, thick, cross, braille]
-p, --pause <PAUSE> --menu Open menu.
Pause time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss' -r, --reset Reset stored values to defaults.
-d, --decis -n, --notification <NOTIFICATION> Toggle desktop notifications. Experimental. [possible values: on, off]
Show deciseconds. --blink <BLINK> Toggle blink mode to animate a clock when it reaches its finished mode. [possible values: on, off]
-m, --mode <MODE> --log [<LOG>] Directory for log file. If not set, standard application log directory is used (check README for details).
Mode to start with. [possible values: countdown, timer, pomodoro, localtime] -h, --help Print help
-s, --style <STYLE> -V, --version Print version
Style to display time with. [possible values: full, light, medium, dark, thick, cross, braille]
--menu
Open menu.
-r, --reset
Reset stored values to defaults.
-n, --notification <NOTIFICATION>
Toggle desktop notifications. Experimental. [possible values: on, off]
--blink <BLINK>
Toggle blink mode to animate a clock when it reaches its finished mode. [possible values: on, off]
--log [<LOG>]
Directory for log file. If not set, standard application log directory is used (check README for details).
-h, --help
Print help
-V, --version
Print version
``` ```
Extra option (if `--features sound` is enabled by local build only): Extra option (if `--features sound` is enabled by local build only):

View File

@ -2,7 +2,6 @@ use crate::{
args::Args, args::Args,
common::{AppEditMode, AppTime, AppTimeFormat, ClockTypeId, Content, Style, Toggle}, common::{AppEditMode, AppTime, AppTimeFormat, ClockTypeId, Content, Style, Toggle},
constants::TICK_VALUE_MS, constants::TICK_VALUE_MS,
duration::DirectedDuration,
events::{self, TuiEventHandler}, events::{self, TuiEventHandler},
storage::AppStorage, storage::AppStorage,
terminal::Terminal, terminal::Terminal,
@ -106,7 +105,7 @@ impl From<FromAppArgs> for App {
None => { None => {
if args.work.is_some() || args.pause.is_some() { if args.work.is_some() || args.pause.is_some() {
Content::Pomodoro Content::Pomodoro
} else if args.countdown.is_some() || args.countdown_target.is_some() { } else if args.countdown.is_some() {
Content::Countdown Content::Countdown
} }
// in other case just use latest stored state // in other case just use latest stored state
@ -124,28 +123,13 @@ impl From<FromAppArgs> for App {
initial_value_pause: args.pause.unwrap_or(stg.inital_value_pause), initial_value_pause: args.pause.unwrap_or(stg.inital_value_pause),
// invalidate `current_value_pause` if an initial value is set via args // invalidate `current_value_pause` if an initial value is set via args
current_value_pause: args.pause.unwrap_or(stg.current_value_pause), current_value_pause: args.pause.unwrap_or(stg.current_value_pause),
initial_value_countdown: match (&args.countdown, &args.countdown_target) { initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown),
(Some(d), _) => *d,
(None, Some(DirectedDuration::Until(d))) => *d,
// reset for values from "past"
(None, Some(DirectedDuration::Since(_))) => Duration::ZERO,
(None, None) => stg.inital_value_countdown,
},
// invalidate `current_value_countdown` if an initial value is set via args // invalidate `current_value_countdown` if an initial value is set via args
current_value_countdown: match (&args.countdown, &args.countdown_target) { current_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown),
(Some(d), _) => *d, elapsed_value_countdown: match args.countdown {
(None, Some(DirectedDuration::Until(d))) => *d, // reset value if countdown is set by arguments
// `zero` makes values from `past` marked as `DONE` Some(_) => Duration::ZERO,
(None, Some(DirectedDuration::Since(_))) => Duration::ZERO, None => stg.elapsed_value_countdown,
(None, None) => stg.inital_value_countdown,
},
elapsed_value_countdown: match (args.countdown, args.countdown_target) {
// use `Since` duration
(_, Some(DirectedDuration::Since(d))) => d,
// reset values
(_, Some(_)) => Duration::ZERO,
(Some(_), _) => Duration::ZERO,
(_, _) => stg.elapsed_value_countdown,
}, },
current_value_timer: stg.current_value_timer, current_value_timer: stg.current_value_timer,
app_tx, app_tx,

View File

@ -18,11 +18,6 @@ pub struct Args {
)] )]
pub countdown: Option<Duration>, pub countdown: Option<Duration>,
#[arg(long, visible_alias = "ct", value_parser = duration::parse_duration_by_time,
help = "Countdown targeting a specific time in the future or past. Formats: 'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:mm', 'hh:mm:ss', 'hh:mm', 'mm'"
)]
pub countdown_target: Option<duration::DirectedDuration>,
#[arg(long, short, value_parser = duration::parse_duration, #[arg(long, short, value_parser = duration::parse_duration,
help = "Work time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss'" help = "Work time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss'"
)] )]

View File

@ -241,6 +241,7 @@ fn parse_hours(h: &str) -> Result<u8, Report> {
/// - `mm` /// - `mm`
/// ///
/// Returns `DirectedDuration::Until` for future times, `DirectedDuration::Since` for past times /// Returns `DirectedDuration::Until` for future times, `DirectedDuration::Since` for past times
#[allow(dead_code)]
pub fn parse_duration_by_time(arg: &str) -> Result<DirectedDuration, Report> { pub fn parse_duration_by_time(arg: &str) -> Result<DirectedDuration, Report> {
use time::{OffsetDateTime, PrimitiveDateTime, macros::format_description}; use time::{OffsetDateTime, PrimitiveDateTime, macros::format_description};