diff options
author | Carlos Alexandro Becker <caarlos0@users.noreply.github.com> | 2024-07-03 16:19:07 -0300 |
---|---|---|
committer | Carlos Alexandro Becker <caarlos0@users.noreply.github.com> | 2024-07-03 16:20:12 -0300 |
commit | 589d9226a39edeafa05a27fa8233017784cb9835 (patch) | |
tree | 5c705b85127994d3eca1c1a3849c2f8af81c0b84 | |
parent | f1cf0ba7856ec7d8f203a1a2c9b8597b3a0cdb14 (diff) |
feat: allow config from CHARM_CONFIG_HOMEconfig-home
closes #594
closes #495
closes #328
closes #475
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
-rw-r--r-- | config_cmd.go | 6 | ||||
-rw-r--r-- | main.go | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/config_cmd.go b/config_cmd.go index 73aba54..00c6658 100644 --- a/config_cmd.go +++ b/config_cmd.go @@ -23,6 +23,12 @@ width: 80 func defaultConfigFile() string { scope := gap.NewScope(gap.User, "glow") + if c := os.Getenv("CHARM_CONFIG_HOME"); c != "" { + return filepath.Join(c, "glow.yml") + } + if c := os.Getenv("XDG_CONFIG_HOME"); c != "" { + return filepath.Join(c, "glow.yml") + } path, _ := scope.ConfigPath("glow.yml") return path } @@ -395,6 +395,14 @@ func tryLoadConfigFromDefaultPlaces() { os.Exit(1) } + if c := os.Getenv("CHARM_CONFIG_HOME"); c != "" { + viper.AddConfigPath(c) + } + + if c := os.Getenv("XDG_CONFIG_HOME"); c != "" { + viper.AddConfigPath(c) + } + for _, v := range dirs { viper.AddConfigPath(v) } |