aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-12-04 12:37:48 +0100
committerGitHub <noreply@github.com>2021-12-04 12:37:48 +0100
commitd1adc163bd53ace1e816e78131e9a8bacd7c331b (patch)
tree1952142abc6be8e31089a52099cd1ac2d197778c
parent4ab6d91df6fd34aa617640c83a7ce2fa93deae17 (diff)
parent6d0331e112791891a57747e6d296e6ae93f157f4 (diff)
downloadgit-bug-d1adc163bd53ace1e816e78131e9a8bacd7c331b.tar.gz
Merge pull request #705 from GlancingMind/compact-ls-format
Command ls: Add compact format
-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)