aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-02-25 20:18:15 +0100
committerGitHub <noreply@github.com>2019-02-25 20:18:15 +0100
commit5e4a656f85e6145f099c27bfcf42dabe1f317cb2 (patch)
treea955ed9bd73e231bcf22371dd05ce30f86033b77 /commands
parentd380b3c16b4321d9262a49e065b54f0525da7187 (diff)
parent3c0c13bbbe934d0fa9476fa5c07bf04ea5a99b94 (diff)
downloadgit-bug-5e4a656f85e6145f099c27bfcf42dabe1f317cb2.tar.gz
Merge pull request #97 from sladyn98/ls_id_branch
A command to list matching bug id from a prefix
Diffstat (limited to 'commands')
-rw-r--r--commands/ls-id.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/commands/ls-id.go b/commands/ls-id.go
new file mode 100644
index 00000000..b9866828
--- /dev/null
+++ b/commands/ls-id.go
@@ -0,0 +1,35 @@
+package commands
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/MichaelMure/git-bug/cache"
+ "github.com/spf13/cobra"
+)
+
+func runLsID(cmd *cobra.Command, args []string) error {
+
+ var backend *cache.RepoCache
+
+ prefix := args[0]
+
+ for _, id := range backend.AllBugsIds() {
+ if prefix == "" || strings.HasPrefix(id, prefix) {
+ fmt.Println(id)
+ }
+ }
+
+ return nil
+}
+
+var listBugIDCmd = &cobra.Command{
+ Use: "ls-id [<prefix>]",
+ Short: "List Bug Id",
+ PreRunE: loadRepo,
+ RunE: runLsID,
+}
+
+func init() {
+ RootCmd.AddCommand(listBugIDCmd)
+}