diff options
Diffstat (limited to 'commands/ls-id.go')
-rw-r--r-- | commands/ls-id.go | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/commands/ls-id.go b/commands/ls-id.go index 6e6da4c1..b9866828 100644 --- a/commands/ls-id.go +++ b/commands/ls-id.go @@ -4,68 +4,23 @@ import ( "fmt" "strings" - "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/cache" "github.com/spf13/cobra" ) func runLsID(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - _, err := ListAllID() + var backend *cache.RepoCache - if err != nil { - return err - } - - return nil - } - answer, err := ListID(args[0]) - - if err != nil { - return err - } - - if answer == "" { - fmt.Printf("No matching bug Id with prefix %s\n", args[0]) - } else { - fmt.Println(answer) - } - - return nil -} - -//ListID lists the local bug id after taking the prefix as input -func ListID(prefix string) (string, error) { - - IDlist, err := bug.ListLocalIds(repo) + prefix := args[0] - if err != nil { - return "", err - } - - for _, id := range IDlist { - if strings.HasPrefix(id, prefix) { - return id, nil + for _, id := range backend.AllBugsIds() { + if prefix == "" || strings.HasPrefix(id, prefix) { + fmt.Println(id) } } - return "", nil - -} - -//ListAllID lists all the local bug id -func ListAllID() (string, error) { - - IDlist, err := bug.ListLocalIds(repo) - if err != nil { - return "", err - } - - for _, id := range IDlist { - fmt.Println(id) - } - - return "", nil + return nil } var listBugIDCmd = &cobra.Command{ |