(recs []Recommendation)
| 320 | } |
| 321 | |
| 322 | func 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. |
| 379 | func parseNextColumns(columnsStr string) ([]string, error) { |
no test coverage detected