aboutsummaryrefslogtreecommitdiffstats
path: root/commands/list.go
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/list.go
parentd973718567b0f7a7e775dbab2c557f0dda9afa29 (diff)
downloadgit-bug-519c5acdd88fc349e3972862887a6e919eb5e7c2.tar.gz
add a primitive "list" command
Diffstat (limited to 'commands/list.go')
-rw-r--r--commands/list.go36
1 files changed, 36 insertions, 0 deletions
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,
+}