Skip to content

refactor: Phase 4 quality improvements#76

Merged
rianjs merged 4 commits intomainfrom
refactor/phase4-quality
Jan 25, 2026
Merged

refactor: Phase 4 quality improvements#76
rianjs merged 4 commits intomainfrom
refactor/phase4-quality

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 25, 2026

Summary

This PR implements Phase 4 quality improvements from the codebase simplification plan:

Test plan

  • All existing tests pass (make test)
  • Linting passes (make lint)
  • New internal/errors package has comprehensive tests
  • New internal/output package has tests
  • Calendar commands work with the new helper function

Closes #42, #43, #44, #45

🤖 Generated with Claude Code

rianjs and others added 4 commits January 25, 2026 18:36
Create internal/errors package with UserError and SystemError types
to enable clear distinction between user-fixable issues and system
failures. This improves error messages and helps users understand
what action to take.

- UserError: for invalid input, missing config, etc.
- SystemError: for API failures, network issues, etc.
  - Includes Retryable flag for transient errors
- IsRetryable helper function

Closes #42

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create internal/output package with JSON() and JSONStdout() functions
to eliminate identical printJSON() implementations across 4 packages.
JSON() accepts an io.Writer for testability, JSONStdout() is a
convenience wrapper for stdout.

Files consolidated:
- internal/cmd/mail/output.go
- internal/cmd/calendar/output.go
- internal/cmd/contacts/output.go
- internal/cmd/drive/output.go

Closes #43

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create EventListOptions struct and listAndPrintEvents() function
to eliminate duplicated event listing logic across today.go, week.go,
and events.go. Each file had ~30 lines of nearly identical code for
fetching, formatting, and printing calendar events.

EventListOptions provides:
- CalendarID, TimeMin, TimeMax, MaxResults
- JSONOutput flag
- Header and EmptyMessage for display customization

Closes #44

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change exported Service fields to private service fields in all
API client structs to prevent abstraction bypass. External access
to API functionality now goes through interface methods only.

Changes:
- gmail.Client: Service→service, UserID→userID, add GetProfile()
- calendar.Client: Service→service
- contacts.Client: Service→service
- drive.Client: Service→service

Updated consumers to use interface methods instead of direct
Service access.

Closes #45

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rianjs rianjs merged commit 5018613 into main Jan 25, 2026
2 checks passed
@rianjs rianjs deleted the refactor/phase4-quality branch January 25, 2026 23:38
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.

feat: classify errors as user errors vs system errors

1 participant