# HG changeset patch # User Mikael Berthe # Date 1493845137 -7200 # Node ID 0491cc43911e73dd755cc9e771740bdb0226152d # Parent 0a3663970622fd883249337b9575a129b8d4de1f Exit with error if the requested configuration file does not exist Thanks to Alexis Vachette for the testing. diff -r 0a3663970622 -r 0491cc43911e cmd/root.go --- a/cmd/root.go Wed May 03 22:58:37 2017 +0200 +++ b/cmd/root.go Wed May 03 22:58:57 2017 +0200 @@ -183,7 +183,13 @@ viper.AutomaticEnv() // If a config file is found, read it in. - if err := viper.ReadInConfig(); viper.GetBool("verbose") && err == nil { + err := viper.ReadInConfig() + if err != nil { + if cfgFile != "" { + errPrint("Error: cannot read configuration file '%s'", cfgFile) + os.Exit(-1) + } + } else if viper.GetBool("verbose") { errPrint("Using config file: %s", viper.ConfigFileUsed()) } }