feat(cli): add flexible positional day argument

- Add parse_date_arg() to utils.py supporting YYYY-MM-DD, MM-DD, and
  DD-MM formats with either - or / as separator
- Add AmbiguousDateError for two-part dates valid as both MM-DD and DD-MM
- Replace --day flag with a positional optional argument (defaults to today)
- Remove old _parse_date() helper from cli.py
This commit is contained in:
Jef Roosens 2026-05-22 10:42:53 +02:00
parent 715e0988dc
commit 267ad5b1b5
Signed by: Jef Roosens
GPG key ID: 119385BCAA005C21
5 changed files with 170 additions and 25 deletions

View file

@ -55,11 +55,16 @@ Do **not** use `pip` or `python` directly.
# Print CSV to stdout (date defaults to today)
uv run timesheets --input input.md
# Specify a day (positional, accepts YYYY-MM-DD, MM-DD, or DD-MM; - or / separator)
uv run timesheets 2026-05-22 --input input.md
uv run timesheets 05-22 --input input.md
# Write CSV to a file
uv run timesheets --input input.md -o output.csv
# Override the date (DD/MM/YY)
uv run timesheets --input input.md --date 22/05/26
# Override the day (accepts YYYY-MM-DD, MM-DD, or DD-MM; - or / separator)
uv run timesheets --input input.md --day 2026-05-22
uv run timesheets --input input.md --day 05-22
# Use a specific project map file
uv run timesheets --input input.md --map /path/to/project_map.json
@ -73,12 +78,12 @@ cat input.md | uv run timesheets --input -
# Fetch today's entries from Joplin (token via env var)
JOPLIN_TOKEN=your_token uv run timesheets --joplin
# Fetch entries for a specific date from Joplin
uv run timesheets --joplin --date 22/05/26 --token your_token
# Fetch entries for a specific day from Joplin
uv run timesheets 2026-05-22 --joplin --token your_token
```
The `--joplin` flag and the file `input` argument are mutually exclusive.
When `--joplin` is used, only entries matching the target date (from `--date`,
When `--joplin` is used, only entries matching the target day (positional arg,
or today) are returned, filtered by the `# ... YYYY-MM-DD` day heading in the note.
The API token can be provided via: