diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-14 22:19:05 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-14 22:19:05 +0200 |
commit | 519c5acdd88fc349e3972862887a6e919eb5e7c2 (patch) | |
tree | 71704adced2c025b0b1aea8cbc63cf5b9093710d /commands/list.go | |
parent | d973718567b0f7a7e775dbab2c557f0dda9afa29 (diff) | |
download | git-bug-519c5acdd88fc349e3972862887a6e919eb5e7c2.tar.gz |
add a primitive "list" command
Diffstat (limited to 'commands/list.go')
-rw-r--r-- | commands/list.go | 36 |
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, +} |