mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 02:01:43 +03:00
Merge pull request #705 from GlancingMind/compact-ls-format
Command ls: Add compact format
This commit is contained in:
commit
d1adc163bd
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user