PrintCollectionTable prints collections in a formatted table.
(collections []models.Collection)
| 603 | |
| 604 | // PrintCollectionTable prints collections in a formatted table. |
| 605 | func PrintCollectionTable(collections []models.Collection) { |
| 606 | if len(collections) == 0 { |
| 607 | fmt.Println("No collections found.") |
| 608 | return |
| 609 | } |
| 610 | |
| 611 | w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) |
| 612 | fmt.Fprintf(w, "NAME\tSLUG\tITEMS\tDEFAULT\n") |
| 613 | for _, col := range collections { |
| 614 | icon := col.Icon |
| 615 | if icon == "" { |
| 616 | icon = " " |
| 617 | } |
| 618 | def := "" |
| 619 | if col.IsDefault { |
| 620 | def = "yes" |
| 621 | } |
| 622 | fmt.Fprintf(w, "%s %s\t%s\t%d\t%s\n", |
| 623 | icon, col.Name, |
| 624 | col.Slug, |
| 625 | col.ItemCount, |
| 626 | def, |
| 627 | ) |
| 628 | } |
| 629 | w.Flush() |
| 630 | } |
| 631 | |
| 632 | // PrintLinkTable prints item links in a formatted table. |
| 633 | func PrintLinkTable(links []models.ItemLink) { |