You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extract common patterns to centralized helper utilities
Create cmd/helpers package to consolidate repeated patterns across commands
and reduce code duplication by ~200 lines while improving consistency.
New helpers package includes:
- error.go: Centralized error handling with ExitWithError() and ExitOnError()
- config.go: Config/StackEntry types and LoadConfig() functions
- fs.go: Filesystem utilities (WithWorkingDir, ResolveAbsPath, GetConfigDir)
- env.go: Environment variable utilities (GetEnvRequired, GetEnvOrDefault)
Updated commands to use helpers:
- init.go: Move Config types to helpers, use WithWorkingDir, ExitOnError
- check.go: Use LoadConfig, WithWorkingDir, ExitOnError, helpers.StackEntry
- update.go: Use LoadConfig, WithWorkingDir, ExitOnError, helpers.StackEntry
- push.go: Use LoadConfig, GetEnvRequired, ExitOnError, helpers.StackEntry
- fetch_catalog.go: Use ExitOnError for error handling
- autodetect.go: Use WithWorkingDir, ExitOnError
- root.go: Use ExitWithError for error handling
- check_test.go: Update tests to use helpers.StackEntry
Benefits:
- Consistent error handling with standardized exit codes
- Single source of truth for config loading and validation
- Cleaner directory context management
- Better code reusability and maintainability
- All tests passing, build successful
🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <[email protected]>
0 commit comments