diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-28 17:30:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-28 17:30:44 +0300 |
| commit | 0761409497041c752086b9aded08cf9e32e30fd2 (patch) | |
| tree | e62721bc119d4ae435d2609292faea06a68244a4 /internal/hexaiaction | |
| parent | 0ac2d186e84f77d73d924e2c0ce975a17c3a8078 (diff) | |
Add --config flag support across CLI, LSP, and tmux tools
Diffstat (limited to 'internal/hexaiaction')
| -rw-r--r-- | internal/hexaiaction/run.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go index a5f47cf..2a1f940 100644 --- a/internal/hexaiaction/run.go +++ b/internal/hexaiaction/run.go @@ -23,13 +23,15 @@ var ( newClientFromApp = llmutils.NewClientFromApp ) +type configPathKey struct{} + // selectedCustom carries the chosen custom action (if any) from the TUI submenu // to the executor. Cleared after use. var selectedCustom *appconfig.CustomAction func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error { logger := log.New(stderr, "hexai-tmux-action ", log.LstdFlags|log.Lmsgprefix) - cfg := appconfig.Load(logger) + cfg := appconfig.LoadWithOptions(logger, appconfig.LoadOptions{ConfigPath: configPathFromContext(ctx)}) if cfg.StatsWindowMinutes > 0 { stats.SetWindow(time.Duration(cfg.StatsWindowMinutes) * time.Minute) } @@ -77,6 +79,24 @@ func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error { return nil } +// WithConfigPath attaches a config path override to the context for Run/RunCommand. +func WithConfigPath(ctx context.Context, path string) context.Context { + if ctx == nil { + ctx = context.Background() + } + return context.WithValue(ctx, configPathKey{}, strings.TrimSpace(path)) +} + +func configPathFromContext(ctx context.Context) string { + if ctx == nil { + return "" + } + if v, ok := ctx.Value(configPathKey{}).(string); ok { + return strings.TrimSpace(v) + } + return "" +} + func executeAction(ctx context.Context, kind ActionKind, parts InputParts, cfg appconfig.App, client chatDoer, stderr io.Writer) (string, error) { switch kind { case ActionSkip: |
