1package bugcmd
2
3import (
4 "github.com/spf13/cobra"
5
6 "github.com/MichaelMure/git-bug/commands/bug/select"
7 "github.com/MichaelMure/git-bug/commands/completion"
8 "github.com/MichaelMure/git-bug/commands/execenv"
9)
10
11func newBugStatusCommand() *cobra.Command {
12 env := execenv.NewEnv()
13
14 cmd := &cobra.Command{
15 Use: "status [BUG_ID]",
16 Short: "Display the status of a bug",
17 PreRunE: execenv.LoadBackend(env),
18 RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
19 return runBugStatus(env, args)
20 }),
21 ValidArgsFunction: completion.Bug(env),
22 }
23
24 cmd.AddCommand(newBugStatusCloseCommand())
25 cmd.AddCommand(newBugStatusOpenCommand())
26
27 return cmd
28}
29
30func runBugStatus(env *execenv.Env, args []string) error {
31 b, args, err := _select.ResolveBug(env.Backend, args)
32 if err != nil {
33 return err
34 }
35
36 snap := b.Snapshot()
37
38 env.Out.Println(snap.Status)
39
40 return nil
41}