From 2229edacca81aa1306a64b1bf85a735349e80b80 Mon Sep 17 00:00:00 2001 From: divolgin Date: Mon, 19 Aug 2024 12:44:42 -0700 Subject: [PATCH] Show cobra errors --- cli/cmd/customer_create.go | 4 +++- cli/cmd/customer_update.go | 4 +++- cli/cmd/instance_inspect.go | 4 +++- cli/cmd/instance_ls.go | 4 +++- cli/cmd/release_create.go | 4 +++- cli/cmd/release_promote.go | 4 +++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cli/cmd/customer_create.go b/cli/cmd/customer_create.go index 4614c74ec..1bcfc4f44 100644 --- a/cli/cmd/customer_create.go +++ b/cli/cmd/customer_create.go @@ -19,7 +19,7 @@ func (r *runners) InitCustomersCreateCommand(parent *cobra.Command) *cobra.Comma Long: `create a customer`, RunE: r.createCustomer, SilenceUsage: false, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) cmd.Flags().StringVar(&r.args.customerCreateName, "name", "", "Name of the customer") @@ -48,6 +48,8 @@ func (r *runners) InitCustomersCreateCommand(parent *cobra.Command) *cobra.Comma } func (r *runners) createCustomer(cmd *cobra.Command, _ []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }() diff --git a/cli/cmd/customer_update.go b/cli/cmd/customer_update.go index e77c8a6e6..136ccb879 100644 --- a/cli/cmd/customer_update.go +++ b/cli/cmd/customer_update.go @@ -19,7 +19,7 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman Long: `update a customer`, RunE: r.updateCustomer, SilenceUsage: false, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) cmd.Flags().StringVar(&r.args.customerUpdateID, "customer", "", "The ID of the customer to update") @@ -50,6 +50,8 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman } func (r *runners) updateCustomer(cmd *cobra.Command, _ []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }() diff --git a/cli/cmd/instance_inspect.go b/cli/cmd/instance_inspect.go index 2da30a756..7e81f14e1 100644 --- a/cli/cmd/instance_inspect.go +++ b/cli/cmd/instance_inspect.go @@ -14,7 +14,7 @@ func (r *runners) InitInstanceInspectCommand(parent *cobra.Command) *cobra.Comma Long: `Show full details for a customer instance`, RunE: r.inspectInstance, SilenceUsage: false, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) cmd.Flags().StringVar(&r.args.instanceInspectCustomer, "customer", "", "Customer Name or ID") @@ -25,6 +25,8 @@ func (r *runners) InitInstanceInspectCommand(parent *cobra.Command) *cobra.Comma } func (r *runners) inspectInstance(cmd *cobra.Command, _ []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }() diff --git a/cli/cmd/instance_ls.go b/cli/cmd/instance_ls.go index ac015c4e3..57b866180 100644 --- a/cli/cmd/instance_ls.go +++ b/cli/cmd/instance_ls.go @@ -13,7 +13,7 @@ func (r *runners) InitInstanceLSCommand(parent *cobra.Command) *cobra.Command { Long: `list customer instances`, RunE: r.listInstances, SilenceUsage: false, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) @@ -25,6 +25,8 @@ func (r *runners) InitInstanceLSCommand(parent *cobra.Command) *cobra.Command { } func (r *runners) listInstances(cmd *cobra.Command, _ []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }() diff --git a/cli/cmd/release_create.go b/cli/cmd/release_create.go index a781554c3..d75f483dc 100644 --- a/cli/cmd/release_create.go +++ b/cli/cmd/release_create.go @@ -33,7 +33,7 @@ func (r *runners) InitReleaseCreate(parent *cobra.Command) error { Long: `Create a new release by providing YAML configuration for the next release in your sequence.`, SilenceUsage: false, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) @@ -154,6 +154,8 @@ func (r *runners) setKOTSDefaultReleaseParams() error { } func (r *runners) releaseCreate(cmd *cobra.Command, args []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }() diff --git a/cli/cmd/release_promote.go b/cli/cmd/release_promote.go index fafc7380a..891cec0d5 100644 --- a/cli/cmd/release_promote.go +++ b/cli/cmd/release_promote.go @@ -16,7 +16,7 @@ func (r *runners) InitReleasePromote(parent *cobra.Command) { Long: `Set the release for a channel Example: replicated release promote 15 fe4901690971757689f022f7a460f9b2`, - SilenceErrors: true, // this command uses custom error printing + SilenceErrors: false, } parent.AddCommand(cmd) @@ -30,6 +30,8 @@ func (r *runners) InitReleasePromote(parent *cobra.Command) { } func (r *runners) releasePromote(cmd *cobra.Command, args []string) (err error) { + cmd.SilenceErrors = true // this command uses custom error printing + defer func() { printIfError(cmd, err) }()