[#626] Support default config file
Signed-off-by: Tivizi Jing <tivizi@163.com>
This commit is contained in:
parent
48827f42d3
commit
2da5a309f7
1 changed files with 6 additions and 3 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
@ -141,9 +142,11 @@ func initConfig() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search config in home directory with name ".main" (without extension).
|
// Search config in `$HOME/.config/neofs-cli/` or `$PWD` with name "config.yaml"
|
||||||
viper.AddConfigPath(home)
|
viper.AddConfigPath(filepath.Join(home, ".config", "neofs-cli"))
|
||||||
viper.SetConfigName(".config/neofs-cli")
|
viper.AddConfigPath(".")
|
||||||
|
viper.SetConfigName("config")
|
||||||
|
viper.SetConfigType("yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.SetEnvPrefix(envPrefix)
|
viper.SetEnvPrefix(envPrefix)
|
||||||
|
|
Loading…
Reference in a new issue