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