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

Function outputNextTable

apps/cli/internal/cli/next.go:322–376  ·  view source on GitHub ↗
(recs []Recommendation)

Source from the content-addressed store, hash-verified

320}
321
322func outputNextTable(recs []Recommendation) error {
323 r := getRenderer()
324
325 if len(recs) == 0 {
326 if nextScope != "" {
327 fmt.Printf("No actionable tasks found for scope %q.\n", nextScope)
328 } else if nextQuickWins {
329 fmt.Println("No quick wins available.")
330 } else if nextCritical {
331 fmt.Println("No critical path tasks available.")
332 } else {
333 fmt.Println("No actionable tasks found.")
334 }
335 return nil
336 }
337
338 columns, err := parseNextColumns(nextColumns)
339 if err != nil {
340 return err
341 }
342
343 label := "Recommended tasks:"
344 if nextScope != "" {
345 label = fmt.Sprintf("Recommended tasks (scope: %s):", nextScope)
346 }
347 if nextQuickWins {
348 label = "Recommended quick wins:"
349 }
350 if nextCritical {
351 label = "Recommended critical path tasks:"
352 }
353 fmt.Println(formatLabel(label, r))
354 fmt.Println()
355
356 tw := NewTableWriter()
357 headers := make([]string, len(columns))
358 for i, col := range columns {
359 headers[i] = nextColumnDisplayName(col)
360 }
361 tw.AddHeader(headers)
362 tw.AddSeparator()
363
364 for _, rec := range recs {
365 plain := make([]string, len(columns))
366 colored := make([]string, len(columns))
367 for i, col := range columns {
368 plain[i] = getNextColumnValue(&rec, col)
369 colored[i] = colorizeNextColumn(&rec, col, r)
370 }
371 tw.AddRow(plain, colored)
372 }
373
374 tw.Flush(os.Stdout)
375 return nil
376}
377
378// parseNextColumns splits the columns string and validates each column name.
379func parseNextColumns(columnsStr string) ([]string, error) {

Callers 1

runNextFunction · 0.85

Calls 11

AddHeaderMethod · 0.95
AddSeparatorMethod · 0.95
AddRowMethod · 0.95
FlushMethod · 0.95
getRendererFunction · 0.85
parseNextColumnsFunction · 0.85
formatLabelFunction · 0.85
NewTableWriterFunction · 0.85
nextColumnDisplayNameFunction · 0.85
getNextColumnValueFunction · 0.85
colorizeNextColumnFunction · 0.85

Tested by

no test coverage detected