diff options
-rw-r--r-- | commands/commands.go | 1 | ||||
-rw-r--r-- | commands/list.go | 36 |
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, +} |