From 3f4acec9f5f9fdc023e593fe12f5a2a128587bad Mon Sep 17 00:00:00 2001 From: Jens Krause <47693+sectore@users.noreply.github.com> Date: Wed, 1 Oct 2025 12:40:27 +0200 Subject: [PATCH] feat(args): parse `countdown` by given time (past or future) (#112) * feat(args): parse `countdown` by time * fix lint No `Default` for `AppTime` needed... * app: pass `countdown_until` down * fix `parse_duration_by_time` and `parse_duration` to handle different formats they support * fix(countdown): percentage panics `Duration::ZERO` needs to be considered * `DirectedDuration` * fix comment * rename arg: `countdown-target` * `ss`->`mm`, fix formats, update README * alias `--ct` --- Cargo.toml | 2 +- README.md | 41 ++++++--- src/app.rs | 42 +++++---- src/args.rs | 17 ++-- src/common.rs | 8 ++ src/duration.rs | 200 ++++++++++++++++++++++++++++++++++++------- src/widgets/clock.rs | 4 + 7 files changed, 247 insertions(+), 67 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a5869c1..04ac662 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ tracing = "0.1.41" tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } directories = "5.0.1" clap = { version = "4.5.40", features = ["derive"] } -time = { version = "0.3.41", features = ["formatting", "local-offset"] } +time = { version = "0.3.41", features = ["formatting", "local-offset", "parsing", "macros"] } notify-rust = "4.11.7" rodio = { version = "0.20.1", features = [ "symphonia-mp3", diff --git a/README.md b/README.md index 1ed93c1..bcce097 100644 --- a/README.md +++ b/README.md @@ -87,19 +87,34 @@ timr-tui --help Usage: timr-tui [OPTIONS] Options: - -c, --countdown Countdown time to start from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss' - -w, --work Work time to count down from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss' - -p, --pause Pause time to count down from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss' - -d, --decis Show deciseconds. - -m, --mode Mode to start with. [possible values: countdown, timer, pomodoro, localtime] - -s, --style