[repository-quality] Command Registration Architecture Consolidation — main.go at 940 Lines #36268
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-06-02T14:55:00.579Z.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report - Command Registration Architecture
Analysis Date: 2026-06-01 Focus Area: Command Registration Architecture Consolidation Strategy Type: Custom
Executive Summary
cmd/gh-aw/main.gohas grown to 940 lines because 7 cobra commands (new,remove,enable,disable,compile,run,version) remain inline with fullRunEimplementations, while 30+ other commands follow the establishedpkg/cli/New*Command()factory pattern. Theinit()function is 431 lines. The highest-impact violations arecompileCmd(136 lines) andrunCmd(86 lines) — the two most user-facing CLI operations — which are untestable without running the full binary. Estimatedmain.gosize after full migration: ~250 lines.Full Analysis Report
Current State Assessment
cmd/gh-aw/main.gototal linesinit()function sizemain()function sizepkg/cli/patterncompileCmdinline sizerunCmdinline sizeStrengths
New*Command()patternmain()itself is small (41 lines)pkg/cli/commands are independently unit-testableAreas for Improvement
compileCmd— most-used CLI command, inline RunE prevents unit testingrunCmd— inline with substantial flag parsing and delegation logicnewCmd(58 lines) — interactive workflow creation not inpkg/cli/init()431 lines — flag registration bloat that would shrink with migrationremoveCmd,enableCmd,disableCmd,versionCmd— small but inconsistent🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Task 1: Migrate
compileCmdtopkg/cli/compile_command.goPriority: High | Effort: Medium | Code Region:
cmd/gh-aw/main.golines 234–369Description: Extract the inline
compileCmd(lines 234–369) intoNewCompileCommand(validateEngine func(string) error) *cobra.Commandinpkg/cli/compile_command.go. Move all flag registrations frominit()into the factory. Wire viarootCmd.AddCommand(cli.NewCompileCommand(validateEngine)).Acceptance Criteria:
pkg/cli/compile_command.gowithNewCompileCommand()factory existsinit())var compileCmdremoved frommain.gomake build && make test-unitpass;./gh-aw compile --helpunchangedTask 2: Migrate
runCmdtopkg/cli/run_command.goPriority: High | Effort: Medium | Code Region:
cmd/gh-aw/main.golines 370–455Description: Extract
runCmd(lines 370–455) intoNewRunCommand(validateEngine func(string) error) *cobra.Commandinpkg/cli/run_command.go. Move all run flag registrations frominit().Acceptance Criteria:
pkg/cli/run_command.gowithNewRunCommand()factory existsvar runCmdremoved frommain.gomake build && make test-unitpass;./gh-aw run --helpunchangedTask 3: Migrate
newCmd,removeCmd,enableCmd,disableCmdtopkg/cli/Priority: Medium | Effort: Medium | Code Region:
cmd/gh-aw/main.golines 109–233Acceptance Criteria:
pkg/cli/new_command.go,remove_command.go,enable_command.go,disable_command.govar *Cmddeclarations removed frommain.gomake build && make test-unitpass;--helpfor all four commands unchangedTask 4: Add Unit Tests for
compileandrunCommandsPriority: Medium | Effort: Small | Code Region:
pkg/cli/compile_command_test.go,pkg/cli/run_command_test.goAcceptance Criteria:
//go:build !integrationtagmake test-unitpasses📊 Historical Context
Previous Focus Areas
📈 Success Metrics
main.goline count: 940 → ~250init()size: 431 → ~80 linespkg/cli/pattern: 30 → 37 (100%)References:
Beta Was this translation helpful? Give feedback.
All reactions