refactor(test): unify config compat helpers to use cobra subcommand tree
Description
In compat_test.go, the test compatibility helpers for config commands use manual arg slicing and hand-written dispatch, while all other helpers in the same file use cobra subcommand trees:
| Function | Style | Lines |
|---|---|---|
parseReviewFlags |
cobra ✅ | 7–21 |
parseScanFlags |
cobra ✅ | 54–69 |
runSession |
cobra ✅ | 110–130 |
parseConfigArgs |
manual slicing ❌ | 30–49 |
runConfig |
manual dispatch ❌ | 136–166 |
parseConfigArgs manually checks len(args) and slices into a configAction struct. runConfig does a switch args[0] to route subcommands — duplicating the routing that config_cmd.go already defines via cobra's AddCommand.
This inconsistency means:
- The test compat layer can drift from production routing logic.
- New config subcommands must be added in both the cobra tree and the manual dispatch.
Scope
- File:
cmd/opencodereview/compat_test.go - Functions:
parseConfigArgs,runConfig,configAction,configParseError - Refactor to use cobra subcommand tree, matching the pattern used by
runSession.
Acceptance Criteria
- [ ]
parseConfigArgsandrunConfigreplaced with cobra-based helpers (similar torunSession) - [ ]
configActionandconfigParseErrortypes removed if no longer needed - [ ] All existing config tests continue to pass with identical behavior
- [ ] Tests pass (
make test) - [ ] Code check passes (
make check)
Context
Discovered during code review of the Cobra CLI migration PR. The other compat helpers were properly migrated to cobra, but the config helpers retained the pre-migration manual parsing style.
would love to take this up.
I'd like to take this. I've rebuilt runConfig on a fresh cobra tree that mirrors the production config command and dropped the manual parseConfigArgs/configAction/configParseError helpers. PR coming.