1package bugcmd
2
3import (
4 "github.com/spf13/cobra"
5
6 "github.com/MichaelMure/git-bug/commands/execenv"
7)
8
9func newBugLabelCommand(env *execenv.Env) *cobra.Command {
10 cmd := &cobra.Command{
11 Use: "label [BUG_ID]",
12 Short: "Display labels of a bug",
13 PreRunE: execenv.LoadBackend(env),
14 RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
15 return runBugLabel(env, args)
16 }),
17 ValidArgsFunction: BugCompletion(env),
18 }
19
20 cmd.AddCommand(newBugLabelNewCommand(env))
21 cmd.AddCommand(newBugLabelRmCommand(env))
22
23 return cmd
24}
25
26func runBugLabel(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.Compile()
33
34 for _, l := range snap.Labels {
35 env.Out.Println(l)
36 }
37
38 return nil
39}