1package commands
 2
 3import (
 4	"fmt"
 5
 6	"github.com/MichaelMure/git-bug/cache"
 7	"github.com/MichaelMure/git-bug/commands/select"
 8	"github.com/MichaelMure/git-bug/util/interrupt"
 9	"github.com/spf13/cobra"
10)
11
12func runStatus(cmd *cobra.Command, args []string) error {
13	backend, err := cache.NewRepoCache(repo)
14	if err != nil {
15		return err
16	}
17	defer backend.Close()
18	interrupt.RegisterCleaner(backend.Close)
19
20	b, args, err := _select.ResolveBug(backend, args)
21	if err != nil {
22		return err
23	}
24
25	snap := b.Snapshot()
26
27	fmt.Println(snap.Status)
28
29	return nil
30}
31
32var statusCmd = &cobra.Command{
33	Use:     "status [<id>]",
34	Short:   "Display or change a bug status.",
35	PreRunE: loadRepo,
36	RunE:    runStatus,
37}
38
39func init() {
40	RootCmd.AddCommand(statusCmd)
41}