aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ls.go
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-08-17 17:07:36 +0200
committerSascha <GlancingMind@outlook.com>2021-08-17 17:07:36 +0200
commit6d0331e112791891a57747e6d296e6ae93f157f4 (patch)
tree05fb2ff2194ffa9338a3d50cf061c79e6f1c20f0 /commands/ls.go
parent663c429605b66d1947d0b7cc50a11cd142494bb2 (diff)
downloadgit-bug-6d0331e112791891a57747e6d296e6ae93f157f4.tar.gz
Command ls: Add compact format
Diffstat (limited to 'commands/ls.go')
-rw-r--r--commands/ls.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/commands/ls.go b/commands/ls.go
index 9134d752..db4145d0 100644
--- a/commands/ls.go
+++ b/commands/ls.go
@@ -133,6 +133,8 @@ func runLs(env *Env, opts lsOptions, args []string) error {
return lsPlainFormatter(env, bugExcerpt)
case "json":
return lsJsonFormatter(env, bugExcerpt)
+ case "compact":
+ return lsCompactFormatter(env, bugExcerpt)
case "default":
return lsDefaultFormatter(env, bugExcerpt)
default:
@@ -203,6 +205,32 @@ func lsJsonFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
return nil
}
+func lsCompactFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
+ for _, b := range bugExcerpts {
+ author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)
+ if err != nil {
+ return err
+ }
+
+ var labelsTxt strings.Builder
+ for _, l := range b.Labels {
+ lc256 := l.Color().Term256()
+ labelsTxt.WriteString(lc256.Escape())
+ labelsTxt.WriteString("◼")
+ labelsTxt.WriteString(lc256.Unescape())
+ }
+
+ env.out.Printf("%s %s %s %s %s\n",
+ colors.Cyan(b.Id.Human()),
+ colors.Yellow(b.Status),
+ text.LeftPadMaxLine(strings.TrimSpace(b.Title), 40, 0),
+ text.LeftPadMaxLine(labelsTxt.String(), 5, 0),
+ colors.Magenta(text.TruncateMax(author.DisplayName(), 15)),
+ )
+ }
+ return nil
+}
+
func lsDefaultFormatter(env *Env, bugExcerpts []*cache.BugExcerpt) error {
for _, b := range bugExcerpts {
author, err := env.backend.ResolveIdentityExcerpt(b.AuthorId)