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