(io *iostreams.IOStreams, results search.CodeResult)
| 161 | } |
| 162 | |
| 163 | func displayResults(io *iostreams.IOStreams, results search.CodeResult) error { |
| 164 | cs := io.ColorScheme() |
| 165 | if io.IsStdoutTTY() { |
| 166 | fmt.Fprintf(io.Out, "\nShowing %d of %d results\n\n", len(results.Items), results.Total) |
| 167 | for i, code := range results.Items { |
| 168 | if i > 0 { |
| 169 | fmt.Fprint(io.Out, "\n") |
| 170 | } |
| 171 | fmt.Fprintf(io.Out, "%s %s\n", cs.Blue(code.Repository.FullName), cs.GreenBold(code.Path)) |
| 172 | for _, match := range code.TextMatches { |
| 173 | lines := formatMatch(match.Fragment, match.Matches, io) |
| 174 | for _, line := range lines { |
| 175 | fmt.Fprintf(io.Out, "\t%s\n", strings.TrimSpace(line)) |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | return nil |
| 180 | } |
| 181 | for _, code := range results.Items { |
| 182 | for _, match := range code.TextMatches { |
| 183 | lines := formatMatch(match.Fragment, match.Matches, io) |
| 184 | for _, line := range lines { |
| 185 | fmt.Fprintf(io.Out, "%s:%s: %s\n", cs.Blue(code.Repository.FullName), cs.GreenBold(code.Path), strings.TrimSpace(line)) |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | return nil |
| 190 | } |
| 191 | |
| 192 | func formatMatch(t string, matches []search.Match, io *iostreams.IOStreams) []string { |
| 193 | cs := io.ColorScheme() |
no test coverage detected