Reject invalid --format and --period values instead of silently falling back (#258)

getDateRange() silently fell back to week on unknown periods, and no command
validated --format. A typo like --period mounth or --format yaml produced
wrong output with exit 0. Now all 6 format-accepting commands and all
period-accepting paths reject unknown values with a clear message and exit 1.
Also fixes the status description (said today+week+month, only shows
today+month).
This commit is contained in:
Resham Joshi 2026-05-06 23:03:41 -07:00 committed by GitHub
parent daa673449c
commit fb8f25fb97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 7 deletions

View file

@ -81,10 +81,8 @@ describe('getDateRange', () => {
expect(range.end.getHours()).toBe(23)
})
it('unknown period falls back to "week"', () => {
const fallback = getDateRange('not-a-period')
const week = getDateRange('week')
expect(fallback.label).toBe(week.label)
it('unknown period exits with an error instead of silently falling back', () => {
expect(() => getDateRange('not-a-period')).toThrow()
})
})