aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorludovicm67 <ludovicmuller1@gmail.com>2019-10-28 12:43:24 +0100
committerludovicm67 <ludovicmuller1@gmail.com>2019-10-28 12:43:24 +0100
commit809abf9244f64683fe2d9f8489a4dcff0904d5b5 (patch)
tree57d01c988227d3dc356c3f0385c12776d0d051f3
parentc9e824152d3d32a654e54bb7e9939f19b6b835ac (diff)
downloadgit-bug-809abf9244f64683fe2d9f8489a4dcff0904d5b5.tar.gz
ls: add labels color + formatting for comments
-rw-r--r--commands/ls.go27
1 files 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,
)
}