aboutsummaryrefslogblamecommitdiffstats
path: root/commands/ls.go
blob: 2101dc84ea23b12439a0462c22b2bb5d14e1d146 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                                   
                                                          




















                                                                    
                     


                                               
                            
 
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\n", bug.HumanId(), snapshot.Title)
	}

	return nil
}

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