(io *iostreams.IOStreams, now time.Time, results search.RepositoriesResult)
| 159 | } |
| 160 | |
| 161 | func displayResults(io *iostreams.IOStreams, now time.Time, results search.RepositoriesResult) error { |
| 162 | if now.IsZero() { |
| 163 | now = time.Now() |
| 164 | } |
| 165 | cs := io.ColorScheme() |
| 166 | tp := tableprinter.New(io, tableprinter.WithHeader("Name", "Description", "Visibility", "Updated")) |
| 167 | for _, repo := range results.Items { |
| 168 | tags := []string{visibilityLabel(repo)} |
| 169 | if repo.IsFork { |
| 170 | tags = append(tags, "fork") |
| 171 | } |
| 172 | if repo.IsArchived { |
| 173 | tags = append(tags, "archived") |
| 174 | } |
| 175 | info := strings.Join(tags, ", ") |
| 176 | infoColor := cs.Muted |
| 177 | if repo.IsPrivate { |
| 178 | infoColor = cs.Yellow |
| 179 | } |
| 180 | tp.AddField(repo.FullName, tableprinter.WithColor(cs.Bold)) |
| 181 | tp.AddField(text.RemoveExcessiveWhitespace(repo.Description)) |
| 182 | tp.AddField(info, tableprinter.WithColor(infoColor)) |
| 183 | tp.AddTimeField(now, repo.UpdatedAt, cs.Muted) |
| 184 | tp.EndRow() |
| 185 | } |
| 186 | if io.IsStdoutTTY() { |
| 187 | header := fmt.Sprintf("Showing %d of %d repositories\n\n", len(results.Items), results.Total) |
| 188 | fmt.Fprintf(io.Out, "\n%s", header) |
| 189 | } |
| 190 | return tp.Render() |
| 191 | } |
| 192 | |
| 193 | func visibilityLabel(repo search.Repository) string { |
| 194 | if repo.Visibility != "" { |
no test coverage detected