git-bug/commands/label.go

36 lines
796 B
Go
Raw Normal View History

2018-07-18 17:41:09 +03:00
package commands
import (
2020-06-28 19:26:29 +03:00
"github.com/spf13/cobra"
2018-08-13 19:32:11 +03:00
"github.com/MichaelMure/git-bug/commands/execenv"
2018-07-18 17:41:09 +03:00
)
2020-06-28 19:26:29 +03:00
func newLabelCommand() *cobra.Command {
env := execenv.NewEnv()
2020-06-28 19:26:29 +03:00
cmd := &cobra.Command{
Use: "label",
Short: "List valid labels",
Long: `List valid labels.
Note: in the future, a proper label policy could be implemented where valid labels are defined in a configuration file. Until that, the default behavior is to return the list of labels already used.`,
PreRunE: execenv.LoadBackend(env),
RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
return runLabel(env)
}),
2020-06-28 19:26:29 +03:00
}
return cmd
}
func runLabel(env *execenv.Env) error {
labels := env.Backend.Bugs().ValidLabels()
for _, l := range labels {
env.Out.Println(l)
2018-07-18 17:41:09 +03:00
}
return nil
2018-07-18 17:41:09 +03:00
}