Skip to content

refactor(cmd): split main.go into cohesive files (under size gate) - #437

Merged
krisarmstrong merged 1 commit into
mainfrom
refactor/split-main-go
Jun 16, 2026
Merged

refactor(cmd): split main.go into cohesive files (under size gate)#437
krisarmstrong merged 1 commit into
mainfrom
refactor/split-main-go

Conversation

@krisarmstrong

Copy link
Copy Markdown
Collaborator

Summary

  • cmd/stem/main.go was 1532 lines — over the project >1200-line red flag. Split verbatim along functional seams into six new files in package main (no new packages, no import changes elsewhere, no logic changes).
  • cmd_test.go was renamed to cmd_testmaster.go because Go treats *_test.go files as test files, which hid the package symbols from the non-test build.

Split

File Responsibility Lines
main.go Constants, func main(), dispatchSubcommand(), printVersion(), printUsage() 263
cmd_reflect.go reflectCmd, reflectorStatsLoop, flag parsing, license check, config build 226
cmd_testmaster.go testCmd, parseTestFlags, createTestConfig, parseFrameSizes, license check 316
cmd_test_runners.go Individual RFC-2544/Y.1564 runner funcs, printTestResult, printCSVResults 328
cmd_web.go webCmd 51
cmd_tui.go tuiCmd, tuiReflectMode, tuiTestMode 158
cmd_help.go helpCmd, tutorialCmd, glossaryCmd, listTestsCmd 171
cmd_license.go licenseCmd, displayLicenseStatus 111

Validation

go build ./...                          ✅ clean (pre-existing libpcap dup-lib warning only)
go vet ./cmd/stem/...                   ✅ clean
golangci-lint run ./cmd/stem/...        ✅ 0 issues
go test ./cmd/stem/...                  ✅ ok (0.124s)
check-file-size.sh | grep main.go       ✅ no output (no longer a red flag)

Notes

  • All code moved verbatim — zero logic changes, zero renames.
  • No compat aliases (pre-v1 no-compat law).
  • New filenames follow the existing cmd_ underscore convention established by cmd_install_ca.go.

cmd/stem/main.go was 1532 lines, exceeding the project >1200-line red
flag. Split along natural functional seams into six new files in the
same package main — zero logic changes, zero renames, verbatim moves:

- cmd_reflect.go      reflect subcommand + stats loop + helpers
- cmd_testmaster.go   test subcommand + flag parsing + license check
- cmd_test_runners.go individual RFC-2544/Y.1564 runners + result printing
- cmd_web.go          web subcommand
- cmd_tui.go          tui subcommand (reflect + testmaster modes)
- cmd_help.go         help / tutorial / glossary / list-tests subcommands
- cmd_license.go      license subcommand + status display

main.go now holds only: constants, func main(), dispatchSubcommand(),
printVersion(), printUsage(). 263 lines.

Note: cmd_test.go was renamed to cmd_testmaster.go because Go treats
files ending in _test.go as test files, which hid the package symbols
from the non-test build.
@github-actions github-actions Bot added the go label Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

License Compliance Report

All dependencies pass license compliance checks

Go Dependencies

  • Unknown: 31 package(s)
  • MIT: 26 package(s)
  • BSD-3-Clause: 16 package(s)
  • Apache-2.0: 11 package(s)
  • BSD-2-Clause: 1 package(s)

npm Dependencies

See full report in workflow artifacts

Allowed Licenses: MIT, Apache-2.0, BSD-*, ISC, CC0-1.0, MPL-2.0
Forbidden: GPL, AGPL, SSPL (strong copyleft)

@krisarmstrong
krisarmstrong enabled auto-merge (squash) June 16, 2026 02:28
@krisarmstrong
krisarmstrong merged commit ec976ea into main Jun 16, 2026
38 of 40 checks passed
@krisarmstrong
krisarmstrong deleted the refactor/split-main-go branch June 16, 2026 02:33
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.

1 participant