From 4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 18 Jun 2026 07:45:37 +0300 Subject: ik0 replace test seams with dependency injection --- cmd/hexai-tmux-edit/main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cmd/hexai-tmux-edit/main.go') 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 } -- cgit v1.2.3