(opts *ViewOptions, d *client.Discussion)
| 334 | } |
| 335 | |
| 336 | func printHumanView(opts *ViewOptions, d *client.Discussion) error { |
| 337 | out := opts.IO.Out |
| 338 | cs := opts.IO.ColorScheme() |
| 339 | |
| 340 | numberStr := fmt.Sprintf("#%d", d.Number) |
| 341 | if !d.Closed { |
| 342 | numberStr = cs.Green(numberStr) |
| 343 | } else { |
| 344 | numberStr = cs.Muted(numberStr) |
| 345 | } |
| 346 | fmt.Fprintf(out, "%s %s\n", cs.Bold(d.Title), numberStr) |
| 347 | |
| 348 | state := "Open" |
| 349 | stateColor := cs.Green |
| 350 | if d.Closed { |
| 351 | state = "Closed" |
| 352 | stateColor = cs.Muted |
| 353 | } |
| 354 | |
| 355 | verb := "Started by" |
| 356 | if d.Category.IsAnswerable { |
| 357 | verb = "Asked by" |
| 358 | } |
| 359 | |
| 360 | fmt.Fprintf(out, "%s • %s • %s %s • %s • %s\n", |
| 361 | stateColor(state), |
| 362 | d.Category.Name, |
| 363 | verb, |
| 364 | d.Author.Login, |
| 365 | text.FuzzyAgo(opts.Now(), d.CreatedAt), |
| 366 | text.Pluralize(d.Comments.TotalCount, "comment"), |
| 367 | ) |
| 368 | |
| 369 | if labels := labelList(d.Labels, cs); labels != "" { |
| 370 | fmt.Fprint(out, cs.Bold("Labels: ")) |
| 371 | fmt.Fprintln(out, labels) |
| 372 | } |
| 373 | |
| 374 | var md string |
| 375 | if d.Body == "" { |
| 376 | md = fmt.Sprintf("\n %s\n\n", cs.Muted("No description provided")) |
| 377 | } else { |
| 378 | var err error |
| 379 | md, err = markdown.Render(d.Body, |
| 380 | markdown.WithTheme(opts.IO.TerminalTheme()), |
| 381 | markdown.WithWrap(opts.IO.TerminalWidth())) |
| 382 | if err != nil { |
| 383 | return err |
| 384 | } |
| 385 | } |
| 386 | fmt.Fprintf(out, "\n%s\n", md) |
| 387 | |
| 388 | if reactions := reactionGroupList(d.ReactionGroups); reactions != "" { |
| 389 | fmt.Fprintln(out, reactions) |
| 390 | fmt.Fprintln(out) |
| 391 | } |
| 392 | |
| 393 | // Comments section |
no test coverage detected