1package commands
2
3import (
4 "fmt"
5 "strings"
6
7 "github.com/MichaelMure/git-bug/cache"
8 "github.com/spf13/cobra"
9)
10
11func runLsID(cmd *cobra.Command, args []string) error {
12
13 var backend *cache.RepoCache
14
15 prefix := args[0]
16
17 for _, id := range backend.AllBugsIds() {
18 if prefix == "" || strings.HasPrefix(id, prefix) {
19 fmt.Println(id)
20 }
21 }
22
23 return nil
24}
25
26var listBugIDCmd = &cobra.Command{
27 Use: "ls-id [<prefix>]",
28 Short: "List Bug Id",
29 PreRunE: loadRepo,
30 RunE: runLsID,
31}
32
33func init() {
34 RootCmd.AddCommand(listBugIDCmd)
35}