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 Apr 18, 2023
1 parent 9af08a9 commit f4de46c
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 = envCfg
} else {
flags.Config = filepath.Join(configDir, "config.yml")
}
}

0 comments on commit f4de46c

Please sign in to comment.