Skip to content

--until <date> flag for arbitrary date ranges - #41

Open
dchaudhari7177 wants to merge 1 commit into
notsointresting:mainfrom
dchaudhari7177:feat/until-flag
Open

--until <date> flag for arbitrary date ranges#41
dchaudhari7177 wants to merge 1 commit into
notsointresting:mainfrom
dchaudhari7177:feat/until-flag

Conversation

@dchaudhari7177

Copy link
Copy Markdown
Contributor

loadReport already accepts an exclusive until bound — wrapped --month uses it internally via monthRange() — it just wasn't reachable from the CLI, so a report could only be bounded from below.

Changes

  • --until <date> is parsed and threaded into loadReport() alongside since, for every command, not just wrapped.
  • --month still wins when both are supplied, matching how --since already behaves.
  • Help text documents the bound as exclusive (ignore activity from this date onward), which is the existing LoadOptions.until semantic. So "just last week" is --since 2026-07-14 --until 2026-07-21 → the 14th through the 20th. Say the word if you'd rather it were inclusive and I'll add the +1-day conversion.

On validation

The issue says "validated the same way --since is" — --since currently isn't validated at all, and that's a quiet footgun: bounds are compared as string prefixes against ISO timestamps, so --since last-tuesday sorts above every timestamp and silently returns an empty report rather than erroring.

So I added one shared check applied to both bounds. It stays lenient about shape on purpose — YYYY, YYYY-MM and YYYY-MM-DD are all accepted, because the comparison really is a prefix match and monthRange itself passes YYYY-MM. Only genuinely non-date input is rejected.

That does mean --since now rejects garbage it previously swallowed. I think that's the fix, but it's a behaviour change on an existing flag — happy to scope it back to --until only if you'd prefer.

Tests

In test/cli.test.ts: --until bounds from above, combines with --since for a window (including an empty since == until window, proving exclusivity), works on a non-wrapped command, rejects malformed values on both bounds, and accepts year / year-month / full-date prefixes.

Typecheck and the full suite (86 passing) are green.

Closes #32

@notsointresting

Copy link
Copy Markdown
Owner

Conflict against main now — a few other PRs touching src/cli.ts/themes/index.ts landed first. Could you rebase onto main and resolve? Should just be re-applying your change alongside the others already merged.

loadReport already supported an exclusive 'until' bound — wrapped --month used
it internally via monthRange — but it was not reachable from the CLI, so a
report could only be bounded from below with --since.

Expose --until and thread it into loadReport alongside since, for every command
rather than just wrapped. --month still wins when both are given, matching how
--since already behaves.

Both bounds now get a shared date check. They are compared as string prefixes
against ISO timestamps, so a year or year-month is as valid as a full date
(monthRange depends on that); the check accepts those three shapes and rejects
the typo that would otherwise sort above every timestamp and silently empty the
report.

Closes notsointresting#32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants