Skip to content

Commit f4de46c

Browse files
committed
feat(config): allow to set the configuration path from WTF_CONFIG
1 parent 9af08a9 commit f4de46c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

flags/flags.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,18 @@ func (flags *Flags) Parse() {
161161
return
162162
}
163163

164-
// If no config file is explicitly passed in as a param then set the flag to the default config file
164+
// If no config file is explicitly passed in as a param
165+
// then try the `WTF_CONFIG` environment variable
166+
// then fallback to the default config file to define the default flag value
165167
configDir, err := cfg.WtfConfigDir()
166168
if err != nil {
167169
fmt.Printf("Error: %v\n", err)
168170
os.Exit(1)
169171
}
170-
flags.Config = filepath.Join(configDir, "config.yml")
172+
envCfg := os.Getenv("WTF_CONFIG")
173+
if envCfg == "" {
174+
flags.Config = envCfg
175+
} else {
176+
flags.Config = filepath.Join(configDir, "config.yml")
177+
}
171178
}

0 commit comments

Comments
 (0)