Skip to content

fix(cmd): read --date/--from/--to from cobra flags instead of viper#34

Merged
omarshahine merged 1 commit intosteipete:mainfrom
omarshahine:fix/sleep-flag-parsing
Apr 16, 2026
Merged

fix(cmd): read --date/--from/--to from cobra flags instead of viper#34
omarshahine merged 1 commit intosteipete:mainfrom
omarshahine:fix/sleep-flag-parsing

Conversation

@omarshahine
Copy link
Copy Markdown
Collaborator

Summary

sleep day --date 2026-02-14 ignores the flag and queries today's date instead. Same root cause as #20 (fixed in #31): viper.BindPFlag with generic key names like "date", "from", "to" registers them globally, so flags from different commands collide.

Fix: Read --date, --from, --to directly from cmd.Flags() and remove the stale viper.BindPFlag calls.

Closes #13

Changes

File Change
internal/cmd/sleep.go Read --date from cmd.Flags(), remove viper binding
internal/cmd/sleep_range.go Read --from/--to from cmd.Flags(), remove viper bindings

Test plan

  • eightctl sleep day --date 2026-04-10 queries April 10, not today
  • eightctl sleep day (no flag) defaults to today
  • eightctl sleep range --from 2026-04-10 --to 2026-04-15 passes both dates correctly
  • go test ./... passes

🤖 Generated with Claude Code

viper.BindPFlag with generic names like "date", "from", "to" registers
them globally, so flags from different commands stomp on each other.
Read these values directly from cmd.Flags() and remove the stale viper
bindings.

Closes steipete#13

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@omarshahine omarshahine force-pushed the fix/sleep-flag-parsing branch from b21d78b to 7c2d6cf Compare April 16, 2026 04:56
@omarshahine omarshahine merged commit 121f18a into steipete:main Apr 16, 2026
2 checks passed
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.

--date flag ignored on sleep day command

1 participant