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