Accept multi-digit hours and reject zero-length durations #9

Open
opened 2026-08-17 19:31:25 +00:00 by rosa · 0 comments
Owner

What to build

--duration should accept every duration it documents, and reject the ones it cannot honour.

Two defects in the same parser. Hours are matched as a single digit while minutes and seconds are matched as one-or-more, so any duration of ten hours or longer is rejected:

$ tomate pom start -d 10h "ten hours"
error: invalid value '10h' for '--duration <DURATION>': Failed to parse duration string, ...
$ tomate pom start -d 9h "nine hours"     # works

And every group in the pattern is optional, so an empty string matches and yields a zero-length timer. The parser's own expect claims to catch this and never fires, because a zero TimeDelta is perfectly valid:

$ tomate pom start -d "" empty
Current Pomodoro: empty
Status: Done
Duration: 0s

A zero-length Pomodoro is born already finished, and the progress bar it prints divides by zero.

Acceptance criteria

  • -d 10h, -d 24h, and -d 100h parse successfully
  • -d "" is rejected with the parser's usage message
  • -d 0s, -d 0m, and any other combination totalling zero are rejected with a message that says a duration must be longer than zero
  • The misleading expect about nonzero durations is gone or made true
  • Tests cover multi-digit hours, the empty string, and an explicit zero

Blocked by

None — can start immediately.

## What to build `--duration` should accept every duration it documents, and reject the ones it cannot honour. Two defects in the same parser. Hours are matched as a single digit while minutes and seconds are matched as one-or-more, so any duration of ten hours or longer is rejected: ``` $ tomate pom start -d 10h "ten hours" error: invalid value '10h' for '--duration <DURATION>': Failed to parse duration string, ... $ tomate pom start -d 9h "nine hours" # works ``` And every group in the pattern is optional, so an empty string matches and yields a zero-length timer. The parser's own `expect` claims to catch this and never fires, because a zero `TimeDelta` is perfectly valid: ``` $ tomate pom start -d "" empty Current Pomodoro: empty Status: Done Duration: 0s ``` A zero-length Pomodoro is born already finished, and the progress bar it prints divides by zero. ## Acceptance criteria - [ ] `-d 10h`, `-d 24h`, and `-d 100h` parse successfully - [ ] `-d ""` is rejected with the parser's usage message - [ ] `-d 0s`, `-d 0m`, and any other combination totalling zero are rejected with a message that says a duration must be longer than zero - [ ] The misleading `expect` about nonzero durations is gone or made true - [ ] Tests cover multi-digit hours, the empty string, and an explicit zero ## Blocked by None — can start immediately.
Sign in to join this conversation.
No description provided.