From 96d75d9f1fab87365d7e6b5070eed3a5757c3484 Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Fri, 22 May 2026 09:18:55 -0400 Subject: Refactor CLI for testability and implement hermetic config path injection --- internal/config/config.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'internal/config/config.go') diff --git a/internal/config/config.go b/internal/config/config.go index 5aa8462..d81a1f6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,7 +1,25 @@ package config +import ( + "os" + "path/filepath" +) + type Config struct { Profile string DNSServer string Command []string } + +// GetDefaultProfilesDir returns the standard XDG path for wg-wrap profiles. +func GetDefaultProfilesDir() string { + configHome := os.Getenv("XDG_CONFIG_HOME") + if configHome == "" { + home, err := os.UserHomeDir() + if err != nil { + return "etc/wg-wrap/profiles" // Fallback + } + configHome = filepath.Join(home, ".config") + } + return filepath.Join(configHome, "wg-wrap", "profiles") +} -- cgit v1.2.3