From 809abf9244f64683fe2d9f8489a4dcff0904d5b5 Mon Sep 17 00:00:00 2001 From: ludovicm67 Date: Mon, 28 Oct 2019 12:43:24 +0100 Subject: ls: add labels color + formatting for comments --- commands/ls.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/commands/ls.go b/commands/ls.go index 9c32642e..9993031b 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -65,17 +65,34 @@ func runLsBug(cmd *cobra.Command, args []string) error { name = b.LegacyAuthor.DisplayName() } + labelsTxt := "" + nbLabels := 0 + for _, l := range b.Labels { + lc := l.Color() + lc256 := lc.Term256() + nbLabels++ + if nbLabels >= 5 && len(b.Labels) > 5 { + labelsTxt += " …" + break + } + labelsTxt += lc256.Escape() + " ◼" + lc256.Unescape() + } + // truncate + pad if needed - titleFmt := text.LeftPadMaxLine(b.Title, 50, 0) + titleFmt := text.LeftPadMaxLine(b.Title, 50-(nbLabels*2), 0) authorFmt := text.LeftPadMaxLine(name, 15, 0) - fmt.Printf("%s %s\t%s\t%s\tC:%d L:%d\n", + comments := fmt.Sprintf("%4d 💬", b.LenComments) + if b.LenComments > 9999 { + comments = " ∞ 💬" + } + + fmt.Printf("%s %s\t%s\t%s\t%s\n", colors.Cyan(b.Id.Human()), colors.Yellow(b.Status), - titleFmt, + titleFmt+labelsTxt, colors.Magenta(authorFmt), - b.LenComments, - len(b.Labels), + comments, ) } -- cgit