aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSladyn <gunnerforlife00@gmail.com>2019-02-14 00:38:55 +0530
committerSladyn <gunnerforlife00@gmail.com>2019-02-25 21:20:51 +0530
commit3c0c13bbbe934d0fa9476fa5c07bf04ea5a99b94 (patch)
tree1b3aea42623507dea0724299f1875d18641ff1a0 /commands
parentf70f38c8ee44338e803ba6bb306c13fe1c7f347a (diff)
downloadgit-bug-3c0c13bbbe934d0fa9476fa5c07bf04ea5a99b94.tar.gz
ls-id.go:Add ls-id [<prefix>] command
This file adds the ls-id command which returns the bug id matching the prefix the user enters. If no prefix entered it lists all the BugId's Closes #47
Diffstat (limited to 'commands')
-rw-r--r--commands/ls-id.go59
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{