PrintCollectionTable prints collections in a formatted table.
(collections []models.Collection)
| 506 | |
| 507 | // PrintCollectionTable prints collections in a formatted table. |
| 508 | func PrintCollectionTable(collections []models.Collection) { |
| 509 | if len(collections) == 0 { |
| 510 | fmt.Println("No collections found.") |
| 511 | return |
| 512 | } |
| 513 | |
| 514 | w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) |
| 515 | fmt.Fprintf(w, "NAME\tSLUG\tITEMS\tDEFAULT\n") |
| 516 | for _, col := range collections { |
| 517 | icon := col.Icon |
| 518 | if icon == "" { |
| 519 | icon = " " |
| 520 | } |
| 521 | def := "" |
| 522 | if col.IsDefault { |
| 523 | def = "yes" |
| 524 | } |
| 525 | fmt.Fprintf(w, "%s %s\t%s\t%d\t%s\n", |
| 526 | icon, col.Name, |
| 527 | col.Slug, |
| 528 | col.ItemCount, |
| 529 | def, |
| 530 | ) |
| 531 | } |
| 532 | w.Flush() |
| 533 | } |
| 534 | |
| 535 | // PrintLinkTable prints item links in a formatted table. |
| 536 | func PrintLinkTable(links []models.ItemLink) { |