diff --git a/cmd/proji/cmd/root.go b/cmd/proji/cmd/root.go index 7f0a6efb..41d142c6 100644 --- a/cmd/proji/cmd/root.go +++ b/cmd/proji/cmd/root.go @@ -62,23 +62,25 @@ func init() { projiEnv = &env{Svc: nil, ConfigFolderPath: "", ExcludedPaths: make([]string, 0), Version: "0.20.0"} } + if len(os.Args) > 1 && os.Args[1] != "init" && os.Args[1] != "version" && os.Args[1] != "help" { + cobra.OnInitialize(initConfig, initStorageService) + } +} + +func initConfig() { + // Set platform specific config path var err error projiEnv.ConfigFolderPath, err = config.GetBaseConfigPath() if err != nil { log.Fatalf("Error: %v\n", err) } + viper.AddConfigPath(projiEnv.ConfigFolderPath) - viper.AddConfigPath(projiEnv.UserConfigPath) + // Config name viper.SetConfigName("config") - viper.AutomaticEnv() - if len(os.Args) > 1 && os.Args[1] != "init" && os.Args[1] != "version" && os.Args[1] != "help" { - cobra.OnInitialize(initConfig, initStorageService) - } -} - -func initConfig() { - err := viper.ReadInConfig() + // Read in config + err = viper.ReadInConfig() if err != nil { log.Fatalf("Error: %v\n\nTry and execute: proji init\n", err) }