MCPcopy Create free account
hub / github.com/driangle/taskmd / outputTable

Function outputTable

apps/cli/internal/cli/list.go:316–344  ·  view source on GitHub ↗

outputTable outputs tasks as a formatted table

(tasks []*model.Task, columnsStr string)

Source from the content-addressed store, hash-verified

314
315// outputTable outputs tasks as a formatted table
316func outputTable(tasks []*model.Task, columnsStr string) error {
317 if len(tasks) == 0 {
318 fmt.Println("No tasks found")
319 return nil
320 }
321
322 columns := strings.Split(columnsStr, ",")
323 for i, col := range columns {
324 columns[i] = strings.TrimSpace(col)
325 }
326
327 r := getRenderer()
328 tw := NewTableWriter()
329 tw.AddHeader(columns)
330 tw.AddSeparator()
331
332 for _, task := range tasks {
333 plain := make([]string, len(columns))
334 colored := make([]string, len(columns))
335 for i, col := range columns {
336 plain[i] = getColumnValue(task, col)
337 colored[i] = colorizeColumn(task, col, r)
338 }
339 tw.AddRow(plain, colored)
340 }
341
342 tw.Flush(os.Stdout)
343 return nil
344}
345
346// colorizeColumn returns the column value with color formatting applied.
347func colorizeColumn(task *model.Task, column string, r *lipgloss.Renderer) string {

Callers 2

captureListTableOutputFunction · 0.85
runListFunction · 0.85

Calls 8

AddHeaderMethod · 0.95
AddSeparatorMethod · 0.95
AddRowMethod · 0.95
FlushMethod · 0.95
getRendererFunction · 0.85
NewTableWriterFunction · 0.85
getColumnValueFunction · 0.85
colorizeColumnFunction · 0.85

Tested by 1

captureListTableOutputFunction · 0.68