Skip to content

Commit c9a5306

Browse files
committed
Print 'Using config file' only for generate sub-command
Signed-off-by: Dinesh <[email protected]>
1 parent c41d9a7 commit c9a5306

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmd/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var generateCmd = &cobra.Command{
2424
os.Exit(1)
2525
}
2626

27+
fmt.Println("Using config file:", cfgFile)
2728
kubetmuxpCfg, err := kubetmuxp.NewConfig(cfgFile, fs, kubeCfg)
2829
if err != nil {
2930
fmt.Println(err)

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func initConfig() {
4343

4444
viper.AutomaticEnv()
4545

46-
if err := viper.ReadInConfig(); err == nil {
47-
fmt.Println("Using config file:", viper.ConfigFileUsed())
46+
if err := viper.ReadInConfig(); err != nil {
47+
_, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf("error reading config file %s: %v", viper.ConfigFileUsed(), err))
4848
}
4949
}

0 commit comments

Comments
 (0)