diff options
author | Michael Muré <batolettre@gmail.com> | 2019-11-03 13:09:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-03 13:09:55 +0000 |
commit | 8c7c9880b1adcf876ad63ea39e46e62bd7ebde5d (patch) | |
tree | f9c6369a6593e3c00cfb3c0b45009dfb6d055d7b /commands/ls.go | |
parent | f5193cc76dd1a1c1bb55194a64ef90bae2278115 (diff) | |
parent | 912b5ca320891f2a4f1a88f1a137ce8ee46a1a03 (diff) | |
download | git-bug-8c7c9880b1adcf876ad63ea39e46e62bd7ebde5d.tar.gz |
Merge pull request #228 from ludovicm67/patch-cli-label-colors
Display label colors in termui
Diffstat (limited to 'commands/ls.go')
-rw-r--r-- | commands/ls.go | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/commands/ls.go b/commands/ls.go index 9c32642e..70a948e6 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -4,11 +4,12 @@ import ( "fmt" "strings" + text "github.com/MichaelMure/go-term-text" + "github.com/spf13/cobra" + "github.com/MichaelMure/git-bug/cache" "github.com/MichaelMure/git-bug/util/colors" "github.com/MichaelMure/git-bug/util/interrupt" - "github.com/MichaelMure/git-bug/util/text" - "github.com/spf13/cobra" ) var ( @@ -65,17 +66,30 @@ func runLsBug(cmd *cobra.Command, args []string) error { name = b.LegacyAuthor.DisplayName() } + var labelsTxt strings.Builder + for _, l := range b.Labels { + lc256 := l.Color().Term256() + labelsTxt.WriteString(lc256.Escape()) + labelsTxt.WriteString(" ◼") + labelsTxt.WriteString(lc256.Unescape()) + } + // truncate + pad if needed - titleFmt := text.LeftPadMaxLine(b.Title, 50, 0) + labelsFmt := text.TruncateMax(labelsTxt.String(), 10) + titleFmt := text.LeftPadMaxLine(b.Title, 50-text.Len(labelsFmt), 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+labelsFmt, colors.Magenta(authorFmt), - b.LenComments, - len(b.Labels), + comments, ) } |