ls-id.go: Fixing ls-id

Adding check for length of args
Pulling bugIds from correct backend.
This commit is contained in:
Sladyn 2019-03-05 00:03:38 +05:30
parent fe8b0659c9
commit a45ece05e6

View File

@ -10,9 +10,17 @@ import (
func runLsID(cmd *cobra.Command, args []string) error { func runLsID(cmd *cobra.Command, args []string) error {
var backend *cache.RepoCache backend, err := cache.NewRepoCache(repo)
if err != nil {
return err
}
defer backend.Close()
prefix := args[0] var prefix string
prefix = ""
if len(args) != 0 {
prefix = args[0]
}
for _, id := range backend.AllBugsIds() { for _, id := range backend.AllBugsIds() {
if prefix == "" || strings.HasPrefix(id, prefix) { if prefix == "" || strings.HasPrefix(id, prefix) {