1package commands
 2
 3import (
 4	"fmt"
 5
 6	"github.com/MichaelMure/git-bug/cache"
 7	"github.com/MichaelMure/git-bug/util/interrupt"
 8	"github.com/spf13/cobra"
 9)
10
11func runLsLabel(cmd *cobra.Command, args []string) error {
12	backend, err := cache.NewRepoCache(repo)
13	if err != nil {
14		return err
15	}
16	defer backend.Close()
17	interrupt.RegisterCleaner(backend.Close)
18
19	labels := backend.ValidLabels()
20
21	for _, l := range labels {
22		fmt.Println(l)
23	}
24
25	return nil
26}
27
28var lsLabelCmd = &cobra.Command{
29	Use:   "ls-label",
30	Short: "List valid labels.",
31	Long: `List valid labels.
32
33Note: 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.`,
34	PreRunE: loadRepo,
35	RunE:    runLsLabel,
36}
37
38func init() {
39	RootCmd.AddCommand(lsLabelCmd)
40}