aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/ls-labels.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/commands/ls-labels.go b/commands/ls-labels.go
new file mode 100644
index 00000000..49f4c7cb
--- /dev/null
+++ b/commands/ls-labels.go
@@ -0,0 +1,37 @@
+package commands
+
+import (
+ "fmt"
+
+ "github.com/MichaelMure/git-bug/cache"
+ "github.com/spf13/cobra"
+)
+
+func runLsLabel(cmd *cobra.Command, args []string) error {
+ backend, err := cache.NewRepoCache(repo)
+ if err != nil {
+ return err
+ }
+ defer backend.Close()
+
+ labels := backend.ValidLabels()
+
+ for _, l := range labels {
+ fmt.Println(l)
+ }
+
+ return nil
+}
+
+var lsLabelCmd = &cobra.Command{
+ Use: "ls-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.`,
+ RunE: runLsLabel,
+}
+
+func init() {
+ RootCmd.AddCommand(lsLabelCmd)
+}