feat(path): support for XDG base directories (#95)

closes #93
This commit is contained in:
VERSE
2026-07-31 22:58:09 +07:00
committed by GitHub
parent aba4dc9716
commit bf75dc239b
2 changed files with 19 additions and 2 deletions
+16
View File
@@ -6,6 +6,10 @@ import (
)
func ConfigPath() (string, error) {
configHome := os.Getenv("XDG_CONFIG_HOME")
if configHome != "" {
return filepath.Join(configHome, "iris", "config.toml"), nil
}
dir, err := os.UserConfigDir()
if err != nil {
return "", err
@@ -25,7 +29,19 @@ func StatePath() (string, error) {
return filepath.Join(dataHome, "iris", "state.toml"), nil
}
func HistoryDBPath() (string, error) {
statePath, err := StatePath()
if err != nil {
return "", err
}
return filepath.Join(filepath.Dir(statePath), "history.db"), nil
}
func CachePath() (string, error) {
cacheHome := os.Getenv("XDG_CACHE_HOME")
if cacheHome != "" {
return filepath.Join(cacheHome, "iris"), nil
}
dir, err := os.UserCacheDir()
if err != nil {
return "", err