Skip to content

Commit

Permalink
Merge pull request #262 from garethjevans/rune
Browse files Browse the repository at this point in the history
chore: switch to using RunE where applicable
  • Loading branch information
garethjevans authored Nov 29, 2022
2 parents 85e0c2b + 283e1fb commit 893fad0
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 93 deletions.
7 changes: 2 additions & 5 deletions cmd/dx/dx.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,10 @@ var filePrepender = func(in string) string {
var docsCmd = &cobra.Command{
Use: "docs",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
RootCmd.DisableAutoGenTag = true

err := doc.GenMarkdownTreeCustom(RootCmd, "./docs", filePrepender, linkHandler)
if err != nil {
fmt.Println(err)
}
return doc.GenMarkdownTreeCustom(RootCmd, "./docs", filePrepender, linkHandler)
},
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/contextcmd/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package contextcmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/pkg/errors"
"github.com/plumming/dx/pkg/domain"
"github.com/spf13/cobra"
Expand All @@ -20,13 +19,10 @@ func NewContextCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"ctx", "c"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.MaximumNArgs(1),
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/deletecmd/delete.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package deletecmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +18,10 @@ func NewDeleteCmd() *cobra.Command {
Short: "",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().WithError(err).Fatal("unable to run command")
}
return c.Run()
},
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/deletecmd/delete_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/plumming/dx/pkg/cmd"
"github.com/plumming/dx/pkg/domain"

"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -25,13 +24,10 @@ func NewDeleteReposCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"repositories", "repository"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/editcmd/edit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package editcmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +18,10 @@ func NewEditCmd() *cobra.Command {
Short: "",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().WithError(err).Fatal("unable to run command")
}
return c.Run()
},
}

Expand Down
7 changes: 2 additions & 5 deletions pkg/cmd/editcmd/edit_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ func NewEditConfigCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"configuration"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/getcmd/get.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package getcmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +18,10 @@ func NewGetCmd() *cobra.Command {
Short: "",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().WithError(err).Fatal("unable to run command")
}
return c.Run()
},
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/getcmd/get_issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/plumming/dx/pkg/util"

"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/plumming/dx/pkg/table"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -52,13 +51,10 @@ Get a list of issues with a custom query:
`,
Aliases: []string{"issues", "is"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/getcmd/get_prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/plumming/dx/pkg/util"

"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/plumming/dx/pkg/table"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -53,13 +52,10 @@ Get a list of PRs with a custom query:
`,
Aliases: []string{"pr", "pulls", "pull-requests"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/getcmd/get_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/plumming/dx/pkg/cmd"
"github.com/plumming/dx/pkg/domain"

"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/plumming/dx/pkg/table"
"github.com/spf13/cobra"
)
Expand All @@ -26,13 +25,10 @@ func NewGetReposCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"repositories", "repository"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/importcmd/import.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package importcmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +18,10 @@ func NewImportCmd() *cobra.Command {
Short: "",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().WithError(err).Fatal("unable to run command")
}
return c.Run()
},
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/importcmd/import_context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package importcmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/pkg/errors"
"github.com/plumming/dx/pkg/cmd"
"github.com/plumming/dx/pkg/domain"
Expand All @@ -23,13 +22,10 @@ func NewImportContextCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"ctx", "c"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/namespacecmd/namespace.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package namespacecmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/pkg/errors"
"github.com/plumming/dx/pkg/domain"
"github.com/spf13/cobra"
Expand All @@ -20,13 +19,10 @@ func NewNamespaceCmd() *cobra.Command {
Long: "",
Example: "",
Aliases: []string{"ns"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.MaximumNArgs(1),
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/rebasecmd/rebase.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rebasecmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/pkg/errors"
"github.com/plumming/dx/pkg/domain"
"github.com/spf13/cobra"
Expand All @@ -22,13 +21,10 @@ func NewRebaseCmd() *cobra.Command {
"Uses the default_branch name determined from the GitHub API.",
Example: "",
Aliases: []string{"rb"},
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down
8 changes: 2 additions & 6 deletions pkg/cmd/upgradecmd/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package upgradecmd

import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/spf13/cobra"
)

Expand All @@ -19,13 +18,10 @@ func NewUpgradeCmd() *cobra.Command {
Short: "",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().WithError(err).Fatal("unable to run command")
}
return c.Run()
},
}

Expand Down
7 changes: 2 additions & 5 deletions pkg/cmd/upgradecmd/upgrade_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,10 @@ func NewUpgradeCliCmd() *cobra.Command {
Short: "Upgrade the cli",
Long: "",
Example: "",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
c.Cmd = cmd
c.Args = args
err := c.Run()
if err != nil {
log.Logger().Fatalf("unable to run command: %s", err)
}
return c.Run()
},
Args: cobra.NoArgs,
}
Expand Down

0 comments on commit 893fad0

Please sign in to comment.