ls.go

 1package commands
 2
 3import (
 4	"fmt"
 5	b "github.com/MichaelMure/git-bug/bug"
 6	"github.com/MichaelMure/git-bug/repository"
 7)
 8
 9func RunLsBug(repo repository.Repo, args []string) error {
10	refs, err := repo.ListRefs(b.BugsRefPattern)
11
12	if err != nil {
13		return err
14	}
15
16	for _, ref := range refs {
17		bug, err := b.ReadBug(repo, ref)
18
19		if err != nil {
20			return err
21		}
22
23		snapshot := bug.Compile()
24
25		fmt.Printf("%s %s\n", bug.HumanId(), snapshot.Title)
26	}
27
28	return nil
29}
30
31var lsCmd = &Command{
32	Usage: func(arg0 string) {
33		fmt.Printf("Usage: %s\n", arg0)
34	},
35	RunMethod: RunLsBug,
36}