diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-18 07:45:37 +0300 |
| commit | 4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b (patch) | |
| tree | 2dc708cbb95975d34084eb5afd376871caa13e27 /cmd/hexai-tmux-edit/main.go | |
| parent | ece7dcfd232b780f5650326c8ac2379ca70387d4 (diff) | |
ik0 replace test seams with dependency injection
Diffstat (limited to 'cmd/hexai-tmux-edit/main.go')
| -rw-r--r-- | cmd/hexai-tmux-edit/main.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/hexai-tmux-edit/main.go b/cmd/hexai-tmux-edit/main.go index 6177008..d61f68a 100644 --- a/cmd/hexai-tmux-edit/main.go +++ b/cmd/hexai-tmux-edit/main.go @@ -22,15 +22,18 @@ import ( "codeberg.org/snonux/hexai/internal/tmuxedit" ) -// runTmuxEdit is the seam for testing: override in tests to avoid real tmux. -var runTmuxEdit = tmuxedit.Run +type app struct { + runTmuxEdit func(tmuxedit.Options) error +} + +func newApp() *app { return &app{runTmuxEdit: tmuxedit.Run} } -func main() { os.Exit(runMain(os.Args[1:], os.Stderr)) } +func main() { os.Exit(newApp().runMain(os.Args[1:], os.Stderr)) } // runMain parses flags from args and runs the tmux edit popup. It returns // the process exit code; flag errors return 2 (matching stdlib convention), // runtime failures return 1. -func runMain(args []string, stderr io.Writer) int { +func (a *app) runMain(args []string, stderr io.Writer) int { defaultPath := appconfig.DefaultConfigPath() fs := flag.NewFlagSet("hexai-tmux-edit", flag.ContinueOnError) fs.SetOutput(stderr) @@ -42,7 +45,7 @@ func runMain(args []string, stderr io.Writer) int { } opts := buildOptions(*configPath, *agent, *pane) - if err := runTmuxEdit(opts); err != nil { + if err := a.runTmuxEdit(opts); err != nil { fmt.Fprintln(stderr, err) return 1 } |
