| 107 | } |
| 108 | |
| 109 | func outputSearchTable(results []search.Result, query string) error { |
| 110 | r := getRenderer() |
| 111 | tw := NewTableWriter() |
| 112 | |
| 113 | tw.AddHeader([]string{"ID", "TITLE", "STATUS", "PRIORITY", "MATCH", "SNIPPET"}) |
| 114 | tw.AddSeparator() |
| 115 | |
| 116 | for _, res := range results { |
| 117 | plain := []string{res.ID, res.Title, res.Status, res.Priority, res.MatchLocation, res.Snippet} |
| 118 | colored := []string{ |
| 119 | formatTaskID(res.ID, r), |
| 120 | res.Title, |
| 121 | formatStatus(res.Status, r), |
| 122 | formatPriority(res.Priority, r), |
| 123 | res.MatchLocation, |
| 124 | highlightMatch(res.Snippet, query, r), |
| 125 | } |
| 126 | tw.AddRow(plain, colored) |
| 127 | } |
| 128 | |
| 129 | tw.Flush(os.Stdout) |
| 130 | return nil |
| 131 | } |
| 132 | |
| 133 | func highlightMatch(text, query string, r *lipgloss.Renderer) string { |
| 134 | lowerText := strings.ToLower(text) |