aboutsummaryrefslogtreecommitdiffstats
path: root/commands/status_close.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/status_close.go')
-rw-r--r--commands/status_close.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/commands/status_close.go b/commands/status_close.go
index 08c67e87..2c7079e6 100644
--- a/commands/status_close.go
+++ b/commands/status_close.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 runStatusClose(cmd *cobra.Command, args []string) error {
- backend, err := cache.NewRepoCache(repo)
+func newStatusCloseCommand() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "close [<id>]",
+ Short: "Mark a bug as closed.",
+ PreRunE: loadRepoEnsureUser(env),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runStatusClose(env, args)
+ },
+ }
+
+ return cmd
+}
+
+func runStatusClose(env *Env, args []string) error {
+ backend, err := cache.NewRepoCache(env.repo)
if err != nil {
return err
}
@@ -27,14 +43,3 @@ func runStatusClose(cmd *cobra.Command, args []string) error {
return b.Commit()
}
-
-var closeCmd = &cobra.Command{
- Use: "close [<id>]",
- Short: "Mark a bug as closed.",
- PreRunE: loadRepoEnsureUser,
- RunE: runStatusClose,
-}
-
-func init() {
- statusCmd.AddCommand(closeCmd)
-}