From 1332a6ec0a00b2475bc2b7b35b4c61425361d6b6 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 17 Jul 2018 20:23:14 +0200 Subject: ls: add some colors --- commands/ls.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'commands') diff --git a/commands/ls.go b/commands/ls.go index ac0bcfbb..0d188833 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -4,6 +4,7 @@ import ( "fmt" b "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/repository" + "github.com/MichaelMure/git-bug/util" ) func runLsBug(repo repository.Repo, args []string) error { @@ -22,7 +23,24 @@ func runLsBug(repo repository.Repo, args []string) error { snapshot := bug.Compile() - fmt.Printf("%s %s\t%s\t%s\n", bug.HumanId(), snapshot.Status, snapshot.Title, snapshot.Summary()) + var author b.Person + + if len(snapshot.Comments) > 0 { + create := snapshot.Comments[0] + author = create.Author + } + + // truncate + pad if needed + titleFmt := fmt.Sprintf("%-50.50s", snapshot.Title) + authorFmt := fmt.Sprintf("%-15.15s", author.Name) + + fmt.Printf("%s %s\t%s\t%s\t%s\n", + util.Cyan(bug.HumanId()), + util.Yellow(snapshot.Status), + titleFmt, + util.Magenta(authorFmt), + snapshot.Summary(), + ) } return nil -- cgit