aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-14 22:19:05 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-14 22:19:05 +0200
commit519c5acdd88fc349e3972862887a6e919eb5e7c2 (patch)
tree71704adced2c025b0b1aea8cbc63cf5b9093710d /commands
parentd973718567b0f7a7e775dbab2c557f0dda9afa29 (diff)
downloadgit-bug-519c5acdd88fc349e3972862887a6e919eb5e7c2.tar.gz
add a primitive "list" command
Diffstat (limited to 'commands')
-rw-r--r--commands/commands.go1
-rw-r--r--commands/list.go36
2 files changed, 37 insertions, 0 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 343d1c71..f4e9aef9 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -23,6 +23,7 @@ func (cmd *Command) Run(repo repository.Repo, args []string) error {
// CommandMap defines all of the available (sub)commands.
var CommandMap = map[string]*Command{
+ "list": listCmd,
"new": newCmd,
"pull": pullCmd,
"push": pushCmd,
diff --git a/commands/list.go b/commands/list.go
new file mode 100644
index 00000000..87c417cf
--- /dev/null
+++ b/commands/list.go
@@ -0,0 +1,36 @@
+package commands
+
+import (
+ "fmt"
+ b "github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/repository"
+)
+
+func RunListBug(repo repository.Repo, args []string) error {
+ refs, err := repo.ListRefs(b.BugsRefPattern)
+
+ if err != nil {
+ return err
+ }
+
+ for _, ref := range refs {
+ bug, err := b.ReadBug(repo, ref)
+
+ if err != nil {
+ return err
+ }
+
+ snapshot := bug.Compile()
+
+ fmt.Printf("%s %s\n", bug.HumanId(), snapshot.Title)
+ }
+
+ return nil
+}
+
+var listCmd = &Command{
+ Usage: func(arg0 string) {
+ fmt.Printf("Usage: %s\n", arg0)
+ },
+ RunMethod: RunListBug,
+}