MCPcopy Create free account
hub / github.com/compozy/agh / listBundle

Function listBundle

internal/cli/format.go:53–89  ·  view source on GitHub ↗
(
	jsonValue any,
	items []T,
	humanTitle string,
	humanHeaders []string,
	toonName string,
	toonFields []string,
	humanRow func(T) []string,
	toonRow func(T) []string,
)

Source from the content-addressed store, hash-verified

51}
52
53func listBundle[T any](
54 jsonValue any,
55 items []T,
56 humanTitle string,
57 humanHeaders []string,
58 toonName string,
59 toonFields []string,
60 humanRow func(T) []string,
61 toonRow func(T) []string,
62) outputBundle {
63 return outputBundle{
64 jsonValue: jsonValue,
65 jsonl: func(cmd *cobra.Command) error {
66 return writeJSONLines(cmd, items)
67 },
68 human: func() (string, error) {
69 if humanRow == nil {
70 return "", errors.New("cli: human list row renderer is required")
71 }
72 rows := make([][]string, 0, len(items))
73 for _, item := range items {
74 rows = append(rows, humanRow(item))
75 }
76 return renderHumanTable(humanTitle, humanHeaders, rows), nil
77 },
78 toon: func() (string, error) {
79 if toonRow == nil {
80 return "", errors.New("cli: toon list row renderer is required")
81 }
82 rows := make([][]string, 0, len(items))
83 for _, item := range items {
84 rows = append(rows, toonRow(item))
85 }
86 return renderToonArray(toonName, toonFields, rows), nil
87 },
88 }
89}
90
91type keyValue struct {
92 Label string

Callers 15

logsBundleFunction · 0.85
bundleCatalogBundleFunction · 0.85
workspaceListBundleFunction · 0.85
bridgeListBundleFunction · 0.85
bridgeRoutesBundleFunction · 0.85
bridgeTargetsBundleFunction · 0.85
providerModelListBundleFunction · 0.85
extensionSearchBundleFunction · 0.85
extensionUpdateBundleFunction · 0.85

Calls 4

writeJSONLinesFunction · 0.85
appendFunction · 0.85
renderHumanTableFunction · 0.85
renderToonArrayFunction · 0.85

Tested by 1