Skip to content

Commit

Permalink
Fail if explicitly given config file is not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoolGuy committed Oct 31, 2024
1 parent 3f91845 commit f5ecf9a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ func initConfig() {
viper.AutomaticEnv() // read in environment variables that match

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
if verbose {
_, _ = fmt.Fprintln(os.Stdout, "Using config file:", viper.ConfigFileUsed())
}
err := viper.ReadInConfig()
if cfgFile != "" {
cobra.CheckErr(err)
}
if verbose {
_, _ = fmt.Fprintln(os.Stdout, "Using config file:", viper.ConfigFileUsed())
}
}

Expand Down

0 comments on commit f5ecf9a

Please sign in to comment.