Skip to content

Commit

Permalink
Show cobra errors
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin committed Aug 19, 2024
1 parent c36961c commit 2229eda
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cli/cmd/customer_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}()
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/customer_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}()
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/instance_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}()
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/instance_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}()
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/release_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}()
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/release_promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}()
Expand Down

0 comments on commit 2229eda

Please sign in to comment.