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

Function displayResults

pkg/cmd/search/commits/commits.go:155–174  ·  view source on GitHub ↗
(io *iostreams.IOStreams, now time.Time, results search.CommitsResult)

Source from the content-addressed store, hash-verified

153}
154
155func displayResults(io *iostreams.IOStreams, now time.Time, results search.CommitsResult) error {
156 if now.IsZero() {
157 now = time.Now()
158 }
159 cs := io.ColorScheme()
160 tp := tableprinter.New(io, tableprinter.WithHeader("Repo", "SHA", "Message", "Author", "Created"))
161 for _, commit := range results.Items {
162 tp.AddField(commit.Repo.FullName)
163 tp.AddField(commit.Sha)
164 tp.AddField(text.RemoveExcessiveWhitespace(commit.Info.Message))
165 tp.AddField(commit.Author.Login)
166 tp.AddTimeField(now, commit.Info.Author.Date, cs.Muted)
167 tp.EndRow()
168 }
169 if io.IsStdoutTTY() {
170 header := fmt.Sprintf("Showing %d of %d commits\n\n", len(results.Items), results.Total)
171 fmt.Fprintf(io.Out, "\n%s", header)
172 }
173 return tp.Render()
174}

Callers 1

commitsRunFunction · 0.70

Calls 7

NewFunction · 0.92
WithHeaderFunction · 0.92
ColorSchemeMethod · 0.80
AddTimeFieldMethod · 0.80
IsStdoutTTYMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected