diff options
| author | James O'Doherty <james@theodohertyfamily.com> | 2026-05-22 09:18:55 -0400 |
|---|---|---|
| committer | James O'Doherty <james@theodohertyfamily.com> | 2026-05-22 09:18:55 -0400 |
| commit | 96d75d9f1fab87365d7e6b5070eed3a5757c3484 (patch) | |
| tree | e01144dbb5338826d36f1b07444ebd78407c3bf4 /internal/config/config.go | |
| parent | 756ba94292b408cc4f23d137b2c4c52009b2b38d (diff) | |
Refactor CLI for testability and implement hermetic config path injection
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 18 |
1 files changed, 18 insertions, 0 deletions
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") +} |
