aboutsummaryrefslogtreecommitdiffstats
path: root/commands/title_edit.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-06-28 19:09:32 +0200
committerMichael Muré <batolettre@gmail.com>2020-06-28 19:09:32 +0200
commit536c290dfbe6e0741c56f33659563c528c9f09b1 (patch)
tree79ea46f76ac6f69c2e6cbf3323be7c620c39a510 /commands/title_edit.go
parent26bd1dd11010b4d86cebe2510ad7085a6b316334 (diff)
downloadgit-bug-536c290dfbe6e0741c56f33659563c528c9f09b1.tar.gz
commands: open and close the backend in a single place, simplify commands
Diffstat (limited to 'commands/title_edit.go')
-rw-r--r--commands/title_edit.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/commands/title_edit.go b/commands/title_edit.go
index 853622cd..e2dbc245 100644
--- a/commands/title_edit.go
+++ b/commands/title_edit.go
@@ -3,10 +3,8 @@ 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/input"
- "github.com/MichaelMure/git-bug/util/interrupt"
)
type titleEditOptions struct {
@@ -18,9 +16,10 @@ func newTitleEditCommand() *cobra.Command {
options := titleEditOptions{}
cmd := &cobra.Command{
- Use: "edit [<id>]",
- Short: "Edit a title of a bug.",
- PreRunE: loadRepoEnsureUser(env),
+ Use: "edit [<id>]",
+ Short: "Edit a title of a bug.",
+ PreRunE: loadBackendEnsureUser(env),
+ PostRunE: closeBackend(env),
RunE: func(cmd *cobra.Command, args []string) error {
return runTitleEdit(env, options, args)
},
@@ -37,14 +36,7 @@ func newTitleEditCommand() *cobra.Command {
}
func runTitleEdit(env *Env, opts titleEditOptions, 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
}