Change summary
commands/commands.go | 1 +
commands/list.go | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
Detailed changes
@@ -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,
@@ -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,
+}