From 2da5a309f77fbd24b83a9392f88c822c1f9afd98 Mon Sep 17 00:00:00 2001 From: tivizi Date: Thu, 24 Jun 2021 20:31:50 +0800 Subject: [PATCH] [#626] Support default config file Signed-off-by: Tivizi Jing --- cmd/neofs-cli/modules/root.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index e40282fa..c325380f 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -7,6 +7,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "github.com/mitchellh/go-homedir" @@ -141,9 +142,11 @@ func initConfig() { os.Exit(1) } - // Search config in home directory with name ".main" (without extension). - viper.AddConfigPath(home) - viper.SetConfigName(".config/neofs-cli") + // Search config in `$HOME/.config/neofs-cli/` or `$PWD` with name "config.yaml" + viper.AddConfigPath(filepath.Join(home, ".config", "neofs-cli")) + viper.AddConfigPath(".") + viper.SetConfigName("config") + viper.SetConfigType("yaml") } viper.SetEnvPrefix(envPrefix)