MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / PrintCollectionTable

Function PrintCollectionTable

internal/cli/format.go:605–630  ·  view source on GitHub ↗

PrintCollectionTable prints collections in a formatted table.

(collections []models.Collection)

Source from the content-addressed store, hash-verified

603
604// PrintCollectionTable prints collections in a formatted table.
605func 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.
633func PrintLinkTable(links []models.ItemLink) {

Callers 1

collectionsCmdFunction · 0.92

Calls 1

FlushMethod · 0.45

Tested by

no test coverage detected