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