MCPcopy Create free account
hub / github.com/github/gh-aw / buildTableConfig

Function buildTableConfig

pkg/console/render.go:240–265  ·  view source on GitHub ↗

buildTableConfig builds a TableConfig from a slice of structs

(val reflect.Value, title string)

Source from the content-addressed store, hash-verified

238
239// buildTableConfig builds a TableConfig from a slice of structs
240func buildTableConfig(val reflect.Value, title string) TableConfig {
241 renderLog.Printf("Building table config: title=%s, elements=%d", title, val.Len())
242
243 config := TableConfig{
244 Title: "",
245 }
246
247 if val.Len() == 0 {
248 return config
249 }
250
251 // Get the element type
252 elemType := val.Type().Elem()
253 for elemType.Kind() == reflect.Pointer {
254 elemType = elemType.Elem()
255 }
256
257 // Build headers from struct fields
258 headers, fieldPaths, fieldTags := buildTableHeaders(elemType)
259 config.Headers = headers
260
261 // Build rows
262 config.Rows = buildTableRows(val, fieldPaths, fieldTags)
263
264 return config
265}
266
267// buildTableHeaders extracts column headers, field index paths, and tags from a struct type,
268// flattening anonymous embedded struct fields into the top-level column list.

Callers 2

TestBuildTableConfigFunction · 0.85
renderSliceFunction · 0.85

Calls 3

buildTableHeadersFunction · 0.85
buildTableRowsFunction · 0.85
PrintfMethod · 0.45

Tested by 1

TestBuildTableConfigFunction · 0.68