Skip to content

feat(cli): add date ranges, model filter and JSON output to report commands - #51

Merged
coldhighsun merged 4 commits into
mainfrom
feat/cli-report-options
Oct 9, 2026
Merged

coldhighsun merged 4 commits into
mainfrom
feat/cli-report-options

Conversation

@coldhighsun

Copy link
Copy Markdown
Owner

Summary

  • Report commands (today, week, month, models, hours, sessions) accept --json: camelCase JSON on stdout, no progress bar, and the update check is skipped so scripted calls make no network request. Session durations are emitted as seconds.
  • Date selection: today --date, week/month with --from [--to] or --last <days>, and month --month yyyy-MM. Input is validated in DateRangeResolver (years 2000-2999, at most 3650 days); invalid values print a message to stderr and exit with code 1 instead of throwing.
  • models --model <text> filters by name (case-insensitive). With no match, the table view prints a hint to stderr and --json prints [].
  • export --format now rejects anything but json or csv instead of silently falling back to JSON.
  • BuildHourlyTokenChart renders a note for an empty trend, since an empty BarChart throws.
  • README and CLAUDE.md document the new options.

Notes

  • week/month/today take no --model filter: DailySummary only carries per-model token counts, so per-model messages and cost would need Core changes.
  • sessions still shows aggregate stats only; --top/--sort need a session list that DataService does not expose yet.
  • The since-midnight window on today is now built from the injected clock's own time zone (previously the machine's).

Test plan

  • dotnet build AIUsageMonitor.slnx (no warnings)
  • dotnet test AIUsageMonitor.slnx (303 passed)
  • Manually ran --json, --last, --month, invalid ranges and export --format xml against real local data

Any --format value other than csv used to fall back to JSON silently, so a typo such as xml produced JSON. Validate the option and report an error for anything but json or csv (case-insensitive).
A BarChart without items throws when rendered. Providers always emit the current hour, but guard the renderer so an empty trend shows a note instead of failing the command.
…mmands

today takes --date; week and month take --from/--to or --last (month also --month); models takes --model. The report commands (today, week, month, models, hours, sessions) take --json, which prints camelCase JSON without a progress bar and skips the update check so scripted calls make no network request. Date input is validated in DateRangeResolver (years 2000-2999, at most 3650 days) and invalid values exit with code 1 and a message on stderr. Session durations are emitted as seconds.
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.52607% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/AIUsageMonitor.Cli/Program.cs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coldhighsun
coldhighsun merged commit 31b5f89 into main Oct 9, 2026
9 checks passed
@coldhighsun
coldhighsun deleted the feat/cli-report-options branch October 9, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant