Skip to content

feat(add): support --daystamp for adding datapoints#221

Merged
narthur merged 6 commits intomainfrom
daystamp-arg
Jan 27, 2026
Merged

feat(add): support --daystamp for adding datapoints#221
narthur merged 6 commits intomainfrom
daystamp-arg

Conversation

@narthur
Copy link
Collaborator

@narthur narthur commented Jan 27, 2026

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.

Summary by CodeRabbit

  • New Features

    • Added an optional --daystamp flag to buzz add to submit datapoints for a specific date (YYYYMMDD); success messages include the daystamp when provided.
  • Documentation

    • README and CLI help updated with --daystamp usage, format, examples, and revised command signature.
  • Bug Fixes

    • Improved detection and messaging for misplaced flags and added daystamp input validation.
  • Tests

    • Added tests covering daystamp handling and misplaced-flag scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 27, 2026 14:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Adds optional daystamp support for datapoint submission: new exported CreateDatapointWithDaystamp that prefers daystamp over timestamp, CLI parsing/validation for a --daystamp flag in buzz add, updated tests, docs, and misplaced-flag detection.

Changes

Cohort / File(s) Summary
Core API
beeminder.go
Adds CreateDatapointWithDaystamp(config *Config, goalSlug, timestamp, daystamp, value, comment, requestid string) error; refactors CreateDatapoint to delegate to it. Payload uses daystamp when non-empty, otherwise timestamp.
CLI
main.go
Adds --daystamp (YYYYMMDD) flag to buzz add, validates format, carries daystampForAPI into CreateDatapointWithDaystamp, and updates messages and misplaced-flag handling.
Documentation
README.md
Updates buzz add usage and examples to include optional --daystamp=<date> (YYYYMMDD) and documents behavior when omitted.
Tests
beeminder_test.go
Adds TestCreateDatapointWithDaystamp validating request form uses daystamp when provided and timestamp when omitted; checks auth_token and value fields.
Utilities
utils.go, utils_test.go
detectMisplacedFlag now checks a knownFlags list including --requestid and --daystamp; tests expanded with cases involving --daystamp and multiple flags.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "feat(add): support --daystamp for adding datapoints" accurately summarizes the main change: adding a new --daystamp flag to the add command for specifying datapoint dates.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 27, 2026

🚀 Pre-release Build Ready

Test builds are ready! Install directly using the bin command:

# 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-221

Direct Download Links

Or download binaries directly from the pre-release page:

💡 No GitHub login required for downloads!

🗑️ This pre-release will be automatically deleted when the PR is closed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 add CLI parsing/help/usage to accept and validate --daystamp=YYYYMMDD.
  • Add CreateDatapointWithDaystamp API wrapper and route existing CreateDatapoint through it for backward compatibility.
  • Add unit tests verifying request payload uses daystamp when provided, otherwise timestamp.

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.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@narthur narthur merged commit 4f7ff34 into main Jan 27, 2026
5 checks passed
@narthur narthur deleted the daystamp-arg branch January 27, 2026 15:36
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.

2 participants