MCPcopy Index your code
hub / github.com/coder/coder / filterHeaders

Function filterHeaders

cli/cliui/table.go:37–55  ·  view source on GitHub ↗

filterHeaders filters the headers to only include the columns that are provided in the array. If the array is empty, all headers are included.

(header table.Row, columns []string)

Source from the content-addressed store, hash-verified

35// that are provided in the array. If the array is empty, all
36// headers are included.
37func filterHeaders(header table.Row, columns []string) table.Row {
38 if len(columns) == 0 {
39 return header
40 }
41
42 filteredHeaders := make(table.Row, len(columns))
43 for i, column := range columns {
44 column = strings.ReplaceAll(column, "_", " ")
45
46 for _, headerTextRaw := range header {
47 headerText, _ := headerTextRaw.(string)
48 if strings.EqualFold(column, headerText) {
49 filteredHeaders[i] = headerText
50 break
51 }
52 }
53 }
54 return filteredHeaders
55}
56
57// createColumnConfigs returns configuration to hide columns
58// that are not provided in the array. If the array is empty,

Callers 1

renderTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected