Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show cobra errors #408

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading