aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ls.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
commit17e2ec8f5679c1ba7ae2ea45290e9303beb3c227 (patch)
treec8862ebf6e9e9314361120127bf3fc59877c3e02 /commands/ls.go
parente1f597639bfc2f796f74afa87e41581087f0b26e (diff)
downloadgit-bug-17e2ec8f5679c1ba7ae2ea45290e9303beb3c227.tar.gz
bug: refactor to limit abstraction leak and to have a more reusable code for the UIs
Diffstat (limited to 'commands/ls.go')
-rw-r--r--commands/ls.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/commands/ls.go b/commands/ls.go
index 1bc2afff..5a5d96c6 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -2,28 +2,22 @@ package commands
import (
"fmt"
- b "github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/util"
"github.com/spf13/cobra"
)
func runLsBug(cmd *cobra.Command, args []string) error {
- ids, err := repo.ListRefs(b.BugsRefPattern)
+ bugs := bug.ReadAllLocalBugs(repo)
- if err != nil {
- return err
- }
-
- for _, ref := range ids {
- bug, err := b.ReadBug(repo, b.BugsRefPattern+ref)
-
- if err != nil {
- return err
+ for b := range bugs {
+ if b.Err != nil {
+ return b.Err
}
- snapshot := bug.Compile()
+ snapshot := b.Bug.Compile()
- var author b.Person
+ var author bug.Person
if len(snapshot.Comments) > 0 {
create := snapshot.Comments[0]
@@ -35,7 +29,7 @@ func runLsBug(cmd *cobra.Command, args []string) error {
authorFmt := fmt.Sprintf("%-15.15s", author.Name)
fmt.Printf("%s %s\t%s\t%s\t%s\n",
- util.Cyan(bug.HumanId()),
+ util.Cyan(b.Bug.HumanId()),
util.Yellow(snapshot.Status),
titleFmt,
util.Magenta(authorFmt),