From 526c3f0ed139bbacaa415154a272d96279d26239 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 10 Mar 2026 19:38:06 +0200 Subject: task 80330fc4: deduplicate default config path helper --- cmd/hexai-lsp-server/main.go | 10 +--------- cmd/hexai-tmux-action/main.go | 10 +--------- cmd/hexai-tmux-edit/main.go | 10 +--------- cmd/hexai/main.go | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-) (limited to 'cmd') diff --git a/cmd/hexai-lsp-server/main.go b/cmd/hexai-lsp-server/main.go index e3e458d..6577bc2 100644 --- a/cmd/hexai-lsp-server/main.go +++ b/cmd/hexai-lsp-server/main.go @@ -17,7 +17,7 @@ import ( func main() { defaultLog := defaultLogPath() logPath := flag.String("log", defaultLog, "path to log file (optional)") - defaultCfg := defaultConfigPath() + defaultCfg := appconfig.DefaultConfigPath() configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultCfg)) showVersion := flag.Bool("version", false, "print version and exit") flag.Parse() @@ -32,14 +32,6 @@ func main() { } } -func defaultConfigPath() string { - path, err := appconfig.ConfigPath() - if err != nil { - return "$XDG_CONFIG_HOME/hexai/config.toml" - } - return path -} - // defaultLogPath returns the default LSP log file path in the state directory. // Falls back to the system temp directory if the state directory is unavailable. func defaultLogPath() string { diff --git a/cmd/hexai-tmux-action/main.go b/cmd/hexai-tmux-action/main.go index 32dd725..6249de3 100644 --- a/cmd/hexai-tmux-action/main.go +++ b/cmd/hexai-tmux-action/main.go @@ -15,7 +15,7 @@ func main() { infile := flag.String("infile", "", "Read input from this file instead of stdin") outfile := flag.String("outfile", "", "Write output to this file instead of stdout") uiChild := flag.Bool("ui-child", false, "INTERNAL: run interactive UI and write to -outfile atomically") - defaultPath := defaultConfigPath() + defaultPath := appconfig.DefaultConfigPath() configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultPath)) tmuxTarget := flag.String("tmux-target", "", "tmux split target (advanced)") tmuxSplit := flag.String("tmux-split", "v", "tmux split orientation: v or h") @@ -35,11 +35,3 @@ func main() { os.Exit(1) } } - -func defaultConfigPath() string { - path, err := appconfig.ConfigPath() - if err != nil { - return "$XDG_CONFIG_HOME/hexai/config.toml" - } - return path -} diff --git a/cmd/hexai-tmux-edit/main.go b/cmd/hexai-tmux-edit/main.go index 931d1c4..ea3330b 100644 --- a/cmd/hexai-tmux-edit/main.go +++ b/cmd/hexai-tmux-edit/main.go @@ -22,7 +22,7 @@ import ( ) func main() { - defaultPath := defaultConfigPath() + defaultPath := appconfig.DefaultConfigPath() configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultPath)) agent := flag.String("agent", "", "AI agent name (auto-detected if omitted)") pane := flag.String("pane", "", "tmux target pane ID (e.g. %%5)") @@ -38,11 +38,3 @@ func main() { os.Exit(1) } } - -func defaultConfigPath() string { - path, err := appconfig.ConfigPath() - if err != nil { - return "$XDG_CONFIG_HOME/hexai/config.toml" - } - return path -} diff --git a/cmd/hexai/main.go b/cmd/hexai/main.go index 15fda42..de96bbf 100644 --- a/cmd/hexai/main.go +++ b/cmd/hexai/main.go @@ -25,7 +25,7 @@ func main() { cliEntries = []appconfig.SurfaceConfig{{Provider: cfg.Provider}} } fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError) - defaultPath := defaultConfigPath() + defaultPath := appconfig.DefaultConfigPath() configFlag := fs.String("config", configPath, fmt.Sprintf("path to config file (default: %s)", defaultPath)) showVersion := fs.Bool("version", false, "print version and exit") selectedFlags := make([]bool, len(cliEntries)) @@ -106,11 +106,3 @@ func pickDefaultModel(cfg appconfig.App, provider string) string { return strings.TrimSpace(cfg.OpenAIModel) } } - -func defaultConfigPath() string { - cfgPath, err := appconfig.ConfigPath() - if err != nil { - return "$XDG_CONFIG_HOME/hexai/config.toml" - } - return cfgPath -} -- cgit v1.2.3