cmd/root.go
changeset 65 0491cc43911e
parent 55 e9df533a1c4f
child 66 43d43c8b53aa
--- 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())
 	}
 }