refactor: split monolithic main.go into domain-specific command files#27
Merged
stuffbucket merged 1 commit intomainfrom Feb 11, 2026
Merged
refactor: split monolithic main.go into domain-specific command files#27stuffbucket merged 1 commit intomainfrom
stuffbucket merged 1 commit intomainfrom
Conversation
Extract 2000+ line main.go into 13 focused files with DI via App struct: - app.go: App struct, NewApp(), Manager(), validators, initLogging() - cmd_container.go: init/create/start/stop/lock/unlock/logs/delete/list/status - cmd_shell.go: ssh/shell/exec (incus exec path for bladerunner) - cmd_config.go: config/env display - cmd_theme.go: interactive theme picker and previews - cmd_snapshot.go: snapshot CRUD - cmd_mount.go: mount add/remove/list with seatbelt auth - cmd_vm.go: VM lifecycle commands - cmd_doctor.go: health checks - cmd_image.go: image build/list/exists/publish/lineage - cmd_state.go: state history/show - cmd_help.go: help/version with dashboard - main.go: thin 91-line dispatch Eliminates appConfig global; all state flows through App struct. Fix all errcheck lint issues across bladerunner, doctor, and cmd files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split the 2000+ line
cmd/coop/main.gointo 13 focused files with dependency injection via anAppstruct.Changes
main.goapp.goAppstruct,NewApp(),Manager(), validators,initLogging()cmd_container.gocmd_shell.gocmd_config.gocmd_theme.gocmd_snapshot.gocmd_mount.gocmd_vm.gocmd_doctor.gocmd_image.gocmd_state.gocmd_help.goKey design decisions
Appstruct: All command handlers are methods on*App, which holds*config.ConfigandBuildInfo. No moreappConfigglobal.Manager(): Sandbox manager is created on first use, not at startup. Commands that don't need it (help, version, config) skip the overhead.Verification
golangci-lint run: 0 issuesgo vet ./...: cleango build ./cmd/coop/: OKgo test -race ./...: all pass