feat(add): support --daystamp for adding datapoints#221
Conversation
📝 WalkthroughWalkthroughAdds optional daystamp support for datapoint submission: new exported CreateDatapointWithDaystamp that prefers daystamp over timestamp, CLI parsing/validation for a --daystamp flag in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
🚀 Pre-release Build ReadyTest builds are ready! Install directly using the # Install the pre-release
bin install https://github.com/PinePeakDigital/buzz/releases/tag/pr-221-latest buzz-pr-221# Run the pre-release
buzz-pr-221# Uninstall the pre-release
bin remove buzz-pr-221Direct Download LinksOr download binaries directly from the pre-release page:
|
There was a problem hiding this comment.
Pull request overview
Adds support for an optional --daystamp flag to buzz add, allowing callers to create datapoints for a specific date (YYYYMMDD) while preserving existing behavior when the flag is omitted.
Changes:
- Extend
buzz addCLI parsing/help/usage to accept and validate--daystamp=YYYYMMDD. - Add
CreateDatapointWithDaystampAPI wrapper and route existingCreateDatapointthrough it for backward compatibility. - Add unit tests verifying request payload uses
daystampwhen provided, otherwisetimestamp.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| main.go | Adds --daystamp flag parsing/validation and updates help/usage + success output. |
| beeminder.go | Introduces CreateDatapointWithDaystamp and updates datapoint creation payload selection logic. |
| beeminder_test.go | Adds tests ensuring daystamp vs timestamp is correctly included in POST body. |
Add optional --daystamp flag to the `buzz add` command and propagate it through the datapoint creation path so callers can specify the datapoint date instead of using the current timestamp. - Update CLI help and usage text to include --daystamp and document YYYYMMDD format and ordering rules. - Parse and validate the --daystamp flag in the add command; print a helpful error and exit on invalid format. - Preserve previous behavior by using the current timestamp when no daystamp is provided. - Add CreateDatapointWithDaystamp wrapper and forward CreateDatapoint to it (keeping compatibility); call the new function with the validated daystamp when creating datapoints. - Enhance success messages to include the daystamp when supplied. This allows users and scripts to add datapoints for specific dates (e.g. backfilling) while maintaining idempotency via requestid.
Update the "buzz add" usage and examples to include an optional --daystamp flag and document its format, default behavior, and use cases. Adjust the CLI synopsis so --daystamp and --requestid appear before the positional <goalslug> and <value> arguments. Why: - Users need a way to add datapoints for a specific date (backfill or pre-entry) without relying on current timestamp behavior. - Documenting the YYYYMMDD format and giving an example reduces user errors and support questions. - Moving optional flags before positionals makes the invocation clearer and matches how the tool parses those options.
Extend detectMisplacedFlag to recognize more than just --requestid. Introduce a knownFlags list (including --daystamp) and check each arg against all known flags, returning the first match. Update warning text in main so the usage example includes --daystamp. Expand unit tests to cover --daystamp detection, value forms (e.g. --daystamp=YYYYMMDD), and interactions when both --daystamp and --requestid are present to ensure the first flagged item is returned. These changes improve user feedback when flags are placed after positional arguments and prevent silent misinterpretation of flag-like inputs.
Update help text describe the default --daystamp "current time" instead of "today". This clar that the flag accepts full date in YYYYMMDD format and that the fallback is the current system time, which reduces ambiguity for users running the CLI in different timezones or contexts.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@main.go`:
- Line 830: Update the usage message printed by the fmt.Fprintf call that writes
to os.Stderr so the flag order matches the help text; change the format string
from "buzz add [--daystamp=DATE] [--requestid=ID] goalslug value comment" to use
"--requestid" before "--daystamp" (e.g., "buzz add [--requestid=ID]
[--daystamp=DATE] goalslug value comment") so all examples are consistent with
the help output.
In `@README.md`:
- Line 226: The README example places the flag after positional args which
contradicts the program's documented/implemented behavior (see
printAddUsageAndExit and handleAddCommand); update the example so flags precede
positional arguments (e.g., move --daystamp=20240115 before the positional
"exercise 1") and ensure the usage line matches the warning in handleAddCommand
and printAddUsageAndExit.
Add optional --daystamp flag to the
buzz addcommand and propagate itthrough the datapoint creation path so callers can specify the datapoint
date instead of using the current timestamp.
YYYYMMDD format and ordering rules.
helpful error and exit on invalid format.
daystamp is provided.
it (keeping compatibility); call the new function with the validated
daystamp when creating datapoints.
This allows users and scripts to add datapoints for specific dates (e.g.
backfilling) while maintaining idempotency via requestid.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.