aboutsummaryrefslogtreecommitdiffstats
path: root/commands/termui.go
blob: abfd165fb6a4a95d3f63add6729add62f03e847c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package commands

import (
	"github.com/MichaelMure/git-bug/cache"
	"github.com/MichaelMure/git-bug/termui"
	"github.com/MichaelMure/git-bug/util/interrupt"
	"github.com/spf13/cobra"
)

func runTermUI(cmd *cobra.Command, args []string) error {
	backend, err := cache.NewRepoCache(repo)
	if err != nil {
		return err
	}
	defer backend.Close()
	interrupt.RegisterCleaner(backend.Close)

	return termui.Run(backend)
}

var termUICmd = &cobra.Command{
	Use:     "termui",
	Short:   "Launch the terminal UI",
	PreRunE: loadRepoEnsureUser,
	RunE:    runTermUI,
}

func init() {
	RootCmd.AddCommand(termUICmd)
}