MCPcopy
hub / github.com/cli/cli / displayResults

Function displayResults

pkg/cmd/search/repos/repos.go:161–191  ·  view source on GitHub ↗
(io *iostreams.IOStreams, now time.Time, results search.RepositoriesResult)

Source from the content-addressed store, hash-verified

159}
160
161func 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
193func visibilityLabel(repo search.Repository) string {
194 if repo.Visibility != "" {

Callers 1

reposRunFunction · 0.70

Calls 9

NewFunction · 0.92
WithHeaderFunction · 0.92
ColorSchemeMethod · 0.80
JoinMethod · 0.80
AddTimeFieldMethod · 0.80
IsStdoutTTYMethod · 0.80
visibilityLabelFunction · 0.70
RenderMethod · 0.65

Tested by

no test coverage detected