1package commands
2
3import (
4 "fmt"
5 b "github.com/MichaelMure/git-bug/bug"
6 "github.com/MichaelMure/git-bug/repository"
7 "github.com/MichaelMure/git-bug/util"
8)
9
10func runLsBug(repo repository.Repo, args []string) error {
11 ids, err := repo.ListRefs(b.BugsRefPattern)
12
13 if err != nil {
14 return err
15 }
16
17 for _, ref := range ids {
18 bug, err := b.ReadBug(repo, b.BugsRefPattern+ref)
19
20 if err != nil {
21 return err
22 }
23
24 snapshot := bug.Compile()
25
26 var author b.Person
27
28 if len(snapshot.Comments) > 0 {
29 create := snapshot.Comments[0]
30 author = create.Author
31 }
32
33 // truncate + pad if needed
34 titleFmt := fmt.Sprintf("%-50.50s", snapshot.Title)
35 authorFmt := fmt.Sprintf("%-15.15s", author.Name)
36
37 fmt.Printf("%s %s\t%s\t%s\t%s\n",
38 util.Cyan(bug.HumanId()),
39 util.Yellow(snapshot.Status),
40 titleFmt,
41 util.Magenta(authorFmt),
42 snapshot.Summary(),
43 )
44 }
45
46 return nil
47}
48
49var lsCmd = &Command{
50 Description: "Display a summary of all bugs",
51 Usage: "",
52 RunMethod: runLsBug,
53}