aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ls.go
blob: 1e001ddbae40b19d4c45e24b2425cdf39983f9c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package commands

import (
	"fmt"
	b "github.com/MichaelMure/git-bug/bug"
	"github.com/MichaelMure/git-bug/repository"
)

func runLsBug(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\t%s\n", bug.HumanId(), snapshot.Title, snapshot.Summary())
	}

	return nil
}

var lsCmd = &Command{
	Usage: func(arg0 string) {
		fmt.Printf("Usage: %s ls\n", arg0)
	},
	RunMethod: runLsBug,
}