aboutsummaryrefslogblamecommitdiffstats
path: root/commands/termui.go
blob: 2cdc350773de40909d7486d898fb5772f8ee0ae4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                
                                              
                                               
                                                       



                                                         




                                                
                                                

                                  


                               
                          
                                 
                                           
                                    
                           




                                     
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",
	Aliases: []string{"tui"},
	Short:   "Launch the terminal UI.",
	PreRunE: loadRepoEnsureUser,
	RunE:    runTermUI,
}

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