1package commands
2
3import (
4 "github.com/spf13/cobra"
5)
6
7func newLsLabelCommand() *cobra.Command {
8 env := newEnv()
9
10 cmd := &cobra.Command{
11 Use: "ls-label",
12 Short: "List valid labels.",
13 Long: `List valid labels.
14
15Note: 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.`,
16 PreRunE: loadBackend(env),
17 PostRunE: closeBackend(env),
18 RunE: func(cmd *cobra.Command, args []string) error {
19 return runLsLabel(env)
20 },
21 }
22
23 return cmd
24}
25
26func runLsLabel(env *Env) error {
27 labels := env.backend.ValidLabels()
28
29 for _, l := range labels {
30 env.out.Println(l)
31 }
32
33 return nil
34}