Skip to content

Commit

Permalink
feat(config): allow to set the configuration path from WTF_CONFIG (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed May 21, 2024
1 parent a3a3dbd commit fda94f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,18 @@ func (flags *Flags) Parse() {
return
}

// If no config file is explicitly passed in as a param then set the flag to the default config file
// If no config file is explicitly passed in as a param
// then try the `WTF_CONFIG` environment variable
// then fallback to the default config file to define the default flag value
configDir, err := cfg.WtfConfigDir()
if err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
flags.Config = filepath.Join(configDir, "config.yml")
envCfg := os.Getenv("WTF_CONFIG")
if envCfg == "" {
flags.Config = filepath.Join(configDir, "config.yml")
} else {
flags.Config = envCfg
}
}

0 comments on commit fda94f2

Please sign in to comment.