diff options
author | Michael Muré <batolettre@gmail.com> | 2020-06-28 19:09:32 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-06-28 19:09:32 +0200 |
commit | 536c290dfbe6e0741c56f33659563c528c9f09b1 (patch) | |
tree | 79ea46f76ac6f69c2e6cbf3323be7c620c39a510 /commands/termui.go | |
parent | 26bd1dd11010b4d86cebe2510ad7085a6b316334 (diff) | |
download | git-bug-536c290dfbe6e0741c56f33659563c528c9f09b1.tar.gz git-bug-536c290dfbe6e0741c56f33659563c528c9f09b1.zip |
commands: open and close the backend in a single place, simplify commands
Diffstat (limited to 'commands/termui.go')
-rw-r--r-- | commands/termui.go | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/commands/termui.go b/commands/termui.go index 174d60ec..1470790f 100644 --- a/commands/termui.go +++ b/commands/termui.go @@ -3,19 +3,18 @@ package commands import ( "github.com/spf13/cobra" - "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/termui" - "github.com/MichaelMure/git-bug/util/interrupt" ) func newTermUICommand() *cobra.Command { env := newEnv() cmd := &cobra.Command{ - Use: "termui", - Aliases: []string{"tui"}, - Short: "Launch the terminal UI.", - PreRunE: loadRepoEnsureUser(env), + Use: "termui", + Aliases: []string{"tui"}, + Short: "Launch the terminal UI.", + PreRunE: loadBackendEnsureUser(env), + PostRunE: closeBackend(env), RunE: func(cmd *cobra.Command, args []string) error { return runTermUI(env) }, @@ -25,12 +24,5 @@ func newTermUICommand() *cobra.Command { } func runTermUI(env *Env) error { - backend, err := cache.NewRepoCache(env.repo) - if err != nil { - return err - } - defer backend.Close() - interrupt.RegisterCleaner(backend.Close) - - return termui.Run(backend) + return termui.Run(env.backend) } |