2019-02-08 21:25:19 +03:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
"github.com/MichaelMure/git-bug/cache"
|
2019-02-08 21:25:19 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func runLsID(cmd *cobra.Command, args []string) error {
|
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
var backend *cache.RepoCache
|
2019-02-08 21:25:19 +03:00
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
prefix := args[0]
|
2019-02-08 21:25:19 +03:00
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
for _, id := range backend.AllBugsIds() {
|
|
|
|
if prefix == "" || strings.HasPrefix(id, prefix) {
|
|
|
|
fmt.Println(id)
|
2019-02-08 21:25:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-13 22:08:55 +03:00
|
|
|
return nil
|
2019-02-08 21:25:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var listBugIDCmd = &cobra.Command{
|
|
|
|
Use: "ls-id [<prefix>]",
|
|
|
|
Short: "List Bug Id",
|
|
|
|
PreRunE: loadRepo,
|
|
|
|
RunE: runLsID,
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
RootCmd.AddCommand(listBugIDCmd)
|
|
|
|
}
|