aboutsummaryrefslogtreecommitdiffstats
path: root/commands/status_open.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-06-28 18:26:29 +0200
committerMichael Muré <batolettre@gmail.com>2020-06-28 18:26:29 +0200
commit26bd1dd11010b4d86cebe2510ad7085a6b316334 (patch)
treef1fe939311c75bd615071e96f3d37822cccd77a7 /commands/status_open.go
parentc0dbc149d5c0c3610476ba14a800c9ba803a2c2c (diff)
downloadgit-bug-26bd1dd11010b4d86cebe2510ad7085a6b316334.tar.gz
commands: refactor to avoid globals
Diffstat (limited to 'commands/status_open.go')
-rw-r--r--commands/status_open.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/commands/status_open.go b/commands/status_open.go
index 1b1c426e..ff98fa33 100644
--- a/commands/status_open.go
+++ b/commands/status_open.go
@@ -1,14 +1,30 @@
package commands
import (
+ "github.com/spf13/cobra"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/commands/select"
"github.com/MichaelMure/git-bug/util/interrupt"
- "github.com/spf13/cobra"
)
-func runStatusOpen(cmd *cobra.Command, args []string) error {
- backend, err := cache.NewRepoCache(repo)
+func newStatusOpenCommand() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "open [<id>]",
+ Short: "Mark a bug as open.",
+ PreRunE: loadRepoEnsureUser(env),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runStatusOpen(env, args)
+ },
+ }
+
+ return cmd
+}
+
+func runStatusOpen(env *Env, args []string) error {
+ backend, err := cache.NewRepoCache(env.repo)
if err != nil {
return err
}
@@ -27,14 +43,3 @@ func runStatusOpen(cmd *cobra.Command, args []string) error {
return b.Commit()
}
-
-var openCmd = &cobra.Command{
- Use: "open [<id>]",
- Short: "Mark a bug as open.",
- PreRunE: loadRepoEnsureUser,
- RunE: runStatusOpen,
-}
-
-func init() {
- statusCmd.AddCommand(openCmd)
-}