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

Function buildTableStyleFunc

pkg/console/console.go:241–261  ·  view source on GitHub ↗

buildTableStyleFunc returns the lipgloss style function used by RenderTable. config supplies the ShowTotal/TotalRow flags; ttyCheck detects terminal output; dataRowCount is the number of data rows (excluding any total row).

(config TableConfig, ttyCheck func() bool, dataRowCount int)

Source from the content-addressed store, hash-verified

239// config supplies the ShowTotal/TotalRow flags; ttyCheck detects terminal output;
240// dataRowCount is the number of data rows (excluding any total row).
241func buildTableStyleFunc(config TableConfig, ttyCheck func() bool, dataRowCount int) func(int, int) lipgloss.Style {
242 return func(row, col int) lipgloss.Style {
243 if !ttyCheck() {
244 return lipgloss.NewStyle()
245 }
246 if row == table.HeaderRow {
247 return styles.TableHeader.PaddingLeft(1).PaddingRight(1)
248 }
249 if config.ShowTotal && len(config.TotalRow) > 0 && row == dataRowCount {
250 return styles.TableTotal.PaddingLeft(1).PaddingRight(1)
251 }
252 if row%2 == 0 {
253 return styles.TableCell.PaddingLeft(1).PaddingRight(1)
254 }
255 return lipgloss.NewStyle().
256 Foreground(styles.ColorForeground).
257 Background(styles.ColorTableAltRow).
258 PaddingLeft(1).
259 PaddingRight(1)
260 }
261}
262
263// FormatCommandMessage formats a command execution message
264func FormatCommandMessage(command string) string {

Callers 1

RenderTableFunction · 0.85

Calls 1

BackgroundMethod · 0.80

Tested by

no test coverage detected