-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Overview
Add functionality to list archived goals in the Buzz CLI application.
Current State
- The Beeminder API already provides an endpoint for archived goals:
GET /users/{username}/goals/archived.json - The codebase currently only fetches and displays active goals using
FetchGoals()inbeeminder.go - The
handleListCommand()inmain.gohandles listing active goals
Implementation Details
1. Add API Function for Archived Goals
File: beeminder.go
Add a new function similar to FetchGoals():
func FetchArchivedGoals(config *Config) ([]Goal, error)This function should:
- Call the Beeminder API endpoint:
/api/v1/users/{username}/goals/archived.json - Use the same authentication pattern as
FetchGoals() - Return a slice of
Goalobjects - Include proper error handling and logging
2. Add CLI Command
File: main.go
Add a new command-line flag or subcommand to list archived goals. Options:
- Option A: Add a flag to existing list command:
buzz list --archived - Option B: Create separate command:
buzz list-archivedorbuzz archived
Recommended: Option A for consistency with potential future filters.
3. Display Formatting
Use the existing display patterns from handleListCommand() and handleFilteredCommand():
- Show slug, title, and other relevant metadata
- Consider showing archive date if available
- Maintain consistent formatting with active goal lists
4. Filter Support (Optional Enhancement)
Consider allowing filters on archived goals:
- Search by slug or title
- Filter by goal type
- Sort options (by slug, archive date, etc.)
Technical Considerations
API Response
The archived goals endpoint returns the same Goal structure as active goals, making integration straightforward.
Error Handling
- Handle cases where user has no archived goals
- Provide clear error messages for API failures
- Follow existing error handling patterns in the codebase
Testing
Add tests following the existing patterns:
- Unit tests for
FetchArchivedGoals()(similar to tests inbeeminder_test.go) - Integration tests for the CLI command
- Mock server tests for API interactions
Code Patterns
Follow existing conventions:
- Use
LogRequest()andLogResponse()for API calls - Follow the error wrapping pattern:
fmt.Errorf("failed to...: %w", err) - Maintain consistency with existing command handlers
Suggested Implementation Order
- Add
FetchArchivedGoals()function inbeeminder.go - Add corresponding tests in
beeminder_test.go - Add CLI command/flag in
main.go - Add command handler function
- Update documentation (README.md, help text)
- Test end-to-end functionality
Related Files
beeminder.go- API functionsmain.go- CLI commands and handlersbeeminder_test.go- API function testsmodel.go- Data structures (may need updates if archived goals need special handling)
Additional Notes
- The
Goalstruct already has fields likewon,lost, andfrozenthat may indicate archive status - Consider whether archived goals should be excluded from other commands (e.g.,
buzz next) - Archived goals likely won't have meaningful
losedateor urgency data
Reactions are currently unavailable