(env *execenv.Env, excerpts []*cache.BugExcerpt)
| 213 | } |
| 214 | |
| 215 | func bugsDefaultFormatter(env *execenv.Env, excerpts []*cache.BugExcerpt) error { |
| 216 | width := env.Out.Width() |
| 217 | widthId := entity.HumanIdLength |
| 218 | widthStatus := len("closed") |
| 219 | widthComment := 6 |
| 220 | |
| 221 | widthRemaining := width - |
| 222 | widthId - 1 - |
| 223 | widthStatus - 1 - |
| 224 | widthComment - 1 |
| 225 | |
| 226 | widthTitle := int(float32(widthRemaining-3) * 0.7) |
| 227 | if widthTitle < 0 { |
| 228 | widthTitle = 0 |
| 229 | } |
| 230 | |
| 231 | widthRemaining = widthRemaining - widthTitle - 3 - 2 |
| 232 | widthAuthor := widthRemaining |
| 233 | |
| 234 | for _, b := range excerpts { |
| 235 | author, err := env.Backend.Identities().ResolveExcerpt(b.AuthorId) |
| 236 | if err != nil { |
| 237 | return err |
| 238 | } |
| 239 | |
| 240 | var labelsTxt strings.Builder |
| 241 | for _, l := range b.Labels { |
| 242 | lc256 := l.Color().Term256() |
| 243 | labelsTxt.WriteString(lc256.Escape()) |
| 244 | labelsTxt.WriteString(" ◼") |
| 245 | labelsTxt.WriteString(lc256.Unescape()) |
| 246 | } |
| 247 | |
| 248 | // truncate + pad if needed |
| 249 | labelsFmt := text.TruncateMax(labelsTxt.String(), 10) |
| 250 | titleFmt := text.LeftPadMaxLine(strings.TrimSpace(b.Title), widthTitle-text.Len(labelsFmt), 0) |
| 251 | authorFmt := text.LeftPadMaxLine(author.DisplayName(), widthAuthor, 0) |
| 252 | |
| 253 | comments := fmt.Sprintf("%3d 💬", b.LenComments-1) |
| 254 | if b.LenComments-1 <= 0 { |
| 255 | comments = "" |
| 256 | } |
| 257 | if b.LenComments-1 > 999 { |
| 258 | comments = " ∞ 💬" |
| 259 | } |
| 260 | |
| 261 | env.Out.Printf("%s\t%s\t%s %s %s\n", |
| 262 | colors.Cyan(b.Id().Human()), |
| 263 | colors.Yellow(b.Status), |
| 264 | titleFmt+labelsFmt, |
| 265 | colors.Magenta(authorFmt), |
| 266 | comments, |
| 267 | ) |
| 268 | } |
| 269 | return nil |
| 270 | } |
| 271 | |
| 272 | func bugsPlainFormatter(env *execenv.Env, excerpts []*cache.BugExcerpt) error { |
no test coverage detected