Problem
The cmd/port-selector/main.go file has grown to 625 lines and handles multiple responsibilities:
- Argument parsing
- Port selection business logic
- Output formatting
- All command implementations (list, scan, forget, lock/unlock)
This violates the Single Responsibility Principle and makes the code harder to maintain and test.
Proposed Solution
Extract commands into a separate package:
internal/
└── commands/
├── commands.go # Common types and interfaces
├── run.go # Main port selection logic
├── list.go # --list command
├── scan.go # --scan command
├── forget.go # --forget, --forget-all commands
└── lock.go # --lock, --unlock commands
Benefits
- Better testability (each command can be tested independently)
- Cleaner main.go (just argument routing)
- Easier to add new commands
- Better code organization
Acceptance Criteria
Problem
The
cmd/port-selector/main.gofile has grown to 625 lines and handles multiple responsibilities:This violates the Single Responsibility Principle and makes the code harder to maintain and test.
Proposed Solution
Extract commands into a separate package:
Benefits
Acceptance Criteria
internal/commands/packagemain.gounder 150 lines