Skip to content

Commit

Permalink
fix(cmd): Fix output if wrong subcommand is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 1, 2024
1 parent 7c87b08 commit e2291f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func NewCommand() *cobra.Command {
DisableAutoGenTag: true,

PersistentPreRunE: preRun,
SilenceErrors: true,
}

flags.Kubeconfig(cmd)
Expand Down Expand Up @@ -91,6 +90,7 @@ func preRun(cmd *cobra.Command, _ []string) error {
return err
}
config.InitLog(cmd)
cmd.Root().SilenceErrors = true

if url := viper.GetString(consts.HealthchecksPingURLKey); url != "" {
if handler, err := notifier.NewHealthchecks(url); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func main() {

rootCmd := cmd.NewCommand()
if err := rootCmd.Execute(); err != nil {
log.Error().Msg(err.Error())
if rootCmd.SilenceErrors {
log.Error().Msg(err.Error())
}
util.PostRun(err)
//nolint:gocritic
os.Exit(1)
Expand Down

0 comments on commit e2291f4

Please sign in to comment.