Add --month to report a past billing period - #58
Merged
Conversation
The extension always reported the current billing period, which early in a month is a thin window; the interesting comparison is usually a completed month. A --month YYYY-MM flag now selects the calendar month in UTC to report, defaulting to the current one. A past month runs from its first instant through its last second; the current month runs up to now, as before. Values that do not parse as YYYY-MM, and months that have not started yet, are rejected through printError so the message prints cleanly without --verbose. usage.Period replaces CurrentPeriod and takes the selected month; the collector is unchanged apart from receiving its bounds from the config. The help text, README, and Copilot instructions now describe the selected billing period rather than the current one. Closes #54 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
README documentation corrections remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds --month=YYYY-MM to report current or past UTC billing months, with validation, period-bound calculation, tests, and documentation updates.
Changes:
- Adds month parsing and validation with clean error handling.
- Calculates selected calendar-month boundaries.
- Updates CLI help, tests, README, and project instructions.
File summaries
| File | Summary |
|---|---|
usage/collector.go |
Calculates selected month bounds. |
usage/collector_test.go |
Tests period boundary edge cases. |
README.md |
Documents the new flag; two nit-level corrections are requested for the description and 2026-08 example (2 votes each). |
main.go |
Parses and validates --month. |
main_test.go |
Tests parsing and invalid-month errors. |
.github/copilot-instructions.md |
Updates project guidance. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #54.
Summary
--month YYYY-MM, defaulting to the current month, to select the calendar month in UTC to report. A past month runs from its first instant through its last second; the current month runs up to now, as before.YYYY-MMand months that have not started yet, routing the error throughprintErrorso it prints cleanly without--verbose.usage.Period(month, now)replacesCurrentPeriod; the collector is unchanged apart from receiving its bounds from the config.Testing
just(fmt, vet, staticcheck, golangci-lint, race tests, govulncheck) passes.Period(current month, past month, leap February, December, moments after a month ends),parseMonth(valid values plus future, empty, unpadded, out-of-range, full-date, and month-name inputs), and the clean error output.codiform/gh-actions-usage:--month=2026-03reported 10h 35m across 61 commits, consistent with the API's 208 runs for that window;--month=2026-07and2026-08report zero, which the API confirms; future and malformed months print the clean error and usage text.🤖 Generated with Claude Code