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

Function PrintCollectionTable

internal/cli/format.go:508–533  ·  view source on GitHub ↗

PrintCollectionTable prints collections in a formatted table.

(collections []models.Collection)

Source from the content-addressed store, hash-verified

506
507// PrintCollectionTable prints collections in a formatted table.
508func 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.
536func PrintLinkTable(links []models.ItemLink) {

Callers 1

collectionsCmdFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected