mirror of
https://github.com/spf13/cobra
synced 2024-11-25 07:07:15 +00:00
Set the defaults BEFORE considering a --config CLI argument
This commit is contained in:
parent
9c28e4bbd7
commit
a7a96310e0
1 changed files with 3 additions and 3 deletions
|
@ -57,12 +57,12 @@ func init() {
|
|||
|
||||
// Read in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
if cfgFile != "" { // enable ability to specify config file via flag
|
||||
viper.SetConfigName(".cobra") // name of config file (without extension)
|
||||
viper.AddConfigPath("$HOME") // adding home directory as first search path
|
||||
if cfgFile != "" { // enable ability to specify config file via flag
|
||||
viper.SetConfigFile(cfgFile)
|
||||
}
|
||||
|
||||
viper.SetConfigName(".cobra") // name of config file (without extension)
|
||||
viper.AddConfigPath("$HOME") // adding home directory as first search path
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
|
||||
// If a config file is found, read it in.
|
||||
|
|
Loading…
Reference in a new issue