summaryrefslogtreecommitdiff
path: root/internal/hexaicli/runner.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-18 07:45:37 +0300
committerPaul Buetow <paul@buetow.org>2026-06-18 07:45:37 +0300
commit4ffb22e7f69f1c9c79b095d4e60bad3d97aac55b (patch)
tree2dc708cbb95975d34084eb5afd376871caa13e27 /internal/hexaicli/runner.go
parentece7dcfd232b780f5650326c8ac2379ca70387d4 (diff)
ik0 replace test seams with dependency injection
Diffstat (limited to 'internal/hexaicli/runner.go')
-rw-r--r--internal/hexaicli/runner.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/internal/hexaicli/runner.go b/internal/hexaicli/runner.go
index 3929001..340733c 100644
--- a/internal/hexaicli/runner.go
+++ b/internal/hexaicli/runner.go
@@ -29,10 +29,11 @@ type cliStatusSink interface {
// Runner executes the CLI with injectable configuration, editor, client, and status dependencies.
type Runner struct {
- loadConfig cliConfigLoader
- openEditor cliEditorOpener
- newClient cliClientFactory
- statusSink cliStatusSink
+ loadConfig cliConfigLoader
+ openEditor cliEditorOpener
+ openConfigEditor func(context.Context, string) error
+ newClient cliClientFactory
+ statusSink cliStatusSink
}
type tmuxCLIStatusSink struct{}
@@ -58,10 +59,11 @@ func (tmuxCLIStatusSink) SetGlobal(snapshot stats.Snapshot, provider, model stri
// NewRunner builds a CLI runner with production dependencies.
func NewRunner() *Runner {
return &Runner{
- loadConfig: loadConfigFromContext,
- openEditor: editor.OpenTempAndEdit,
- newClient: newClientFromApp,
- statusSink: tmuxCLIStatusSink{},
+ loadConfig: loadConfigFromContext,
+ openEditor: editor.OpenTempAndEdit,
+ openConfigEditor: editor.OpenFile,
+ newClient: newClientFromApp,
+ statusSink: tmuxCLIStatusSink{},
}
}
@@ -85,7 +87,7 @@ func (r *Runner) Run(ctx context.Context, args []string, stdin io.Reader, stdout
}
cfgPath = p
}
- if err := editor.OpenFile(ctx, cfgPath); err != nil {
+ if err := runner.openConfigEditor(ctx, cfgPath); err != nil {
_, _ = fmt.Fprintf(stderr, logging.AnsiBase+"hexai %s: %v"+logging.AnsiReset+"\n", sub, err)
return err
}
@@ -172,6 +174,9 @@ func normalizeRunner(r *Runner) Runner {
if runner.openEditor == nil {
runner.openEditor = editor.OpenTempAndEdit
}
+ if runner.openConfigEditor == nil {
+ runner.openConfigEditor = editor.OpenFile
+ }
if runner.newClient == nil {
runner.newClient = newClientFromApp
}