aboutsummaryrefslogtreecommitdiffstats
path: root/commands/label_add.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/label_add.go')
-rw-r--r--commands/label_add.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/commands/label_add.go b/commands/label_add.go
index 83a9f064..05a27948 100644
--- a/commands/label_add.go
+++ b/commands/label_add.go
@@ -3,18 +3,17 @@ 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"
)
func newLabelAddCommand() *cobra.Command {
env := newEnv()
cmd := &cobra.Command{
- Use: "add [<id>] <label>[...]",
- Short: "Add a label to a bug.",
- PreRunE: loadRepoEnsureUser(env),
+ Use: "add [<id>] <label>[...]",
+ Short: "Add a label to a bug.",
+ PreRunE: loadBackendEnsureUser(env),
+ PostRunE: closeBackend(env),
RunE: func(cmd *cobra.Command, args []string) error {
return runLabelAdd(env, args)
},
@@ -24,14 +23,7 @@ func newLabelAddCommand() *cobra.Command {
}
func runLabelAdd(env *Env, args []string) error {
- backend, err := cache.NewRepoCache(env.repo)
- if err != nil {
- return err
- }
- defer backend.Close()
- interrupt.RegisterCleaner(backend.Close)
-
- b, args, err := _select.ResolveBug(backend, args)
+ b, args, err := _select.ResolveBug(env.backend, args)
if err != nil {
return err
}