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

Function outputSearchTable

apps/cli/internal/cli/search.go:109–131  ·  view source on GitHub ↗
(results []search.Result, query string)

Source from the content-addressed store, hash-verified

107}
108
109func 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
133func highlightMatch(text, query string, r *lipgloss.Renderer) string {
134 lowerText := strings.ToLower(text)

Callers 2

runSearchFunction · 0.85
captureSearchOutputFunction · 0.85

Calls 10

AddHeaderMethod · 0.95
AddSeparatorMethod · 0.95
AddRowMethod · 0.95
FlushMethod · 0.95
getRendererFunction · 0.85
NewTableWriterFunction · 0.85
formatTaskIDFunction · 0.85
formatStatusFunction · 0.85
formatPriorityFunction · 0.85
highlightMatchFunction · 0.85

Tested by 1

captureSearchOutputFunction · 0.68