MCPcopy
hub / github.com/cli/cli / printHumanIssuePreview

Function printHumanIssuePreview

pkg/cmd/issue/view/view.go:240–353  ·  view source on GitHub ↗
(opts *ViewOptions, baseRepo ghrepo.Interface, issue *api.Issue)

Source from the content-addressed store, hash-verified

238}
239
240func printHumanIssuePreview(opts *ViewOptions, baseRepo ghrepo.Interface, issue *api.Issue) error {
241 out := opts.IO.Out
242 cs := opts.IO.ColorScheme()
243
244 // Header (Title and State)
245 fmt.Fprintf(out, "%s %s#%d\n", cs.Bold(issue.Title), ghrepo.FullName(baseRepo), issue.Number)
246
247 // State line - include issue type prefix when present
248 stateLine := issueStateTitleWithColor(cs, issue)
249 if issue.IssueType != nil {
250 stateLine = cs.Muted(issue.IssueType.Name) + " · " + stateLine
251 }
252 fmt.Fprintf(out,
253 "%s • %s opened %s • %s\n",
254 stateLine,
255 issue.Author.DisplayName(),
256 text.FuzzyAgo(opts.Now(), issue.CreatedAt),
257 text.Pluralize(issue.Comments.TotalCount, "comment"),
258 )
259
260 // Reactions
261 if reactions := prShared.ReactionGroupList(issue.ReactionGroups); reactions != "" {
262 fmt.Fprint(out, reactions)
263 fmt.Fprintln(out)
264 }
265
266 // Metadata
267 if assignees := issueAssigneeList(*issue); assignees != "" {
268 fmt.Fprint(out, cs.Bold("Assignees: "))
269 fmt.Fprintln(out, assignees)
270 }
271 if labels := issueLabelList(issue, cs); labels != "" {
272 fmt.Fprint(out, cs.Bold("Labels: "))
273 fmt.Fprintln(out, labels)
274 }
275 if issue.IssueType != nil {
276 fmt.Fprint(out, cs.Bold("Type: "))
277 fmt.Fprintln(out, issue.IssueType.Name)
278 }
279 if issue.Parent != nil {
280 fmt.Fprint(out, cs.Bold("Parent: "))
281 fmt.Fprintln(out, formatLinkedIssueRef(issue.Parent)+" "+issue.Parent.Title)
282 }
283 if blockedBy := formatLinkedIssueListWithTitle(issue.BlockedBy.Nodes); blockedBy != "" {
284 fmt.Fprint(out, cs.Bold("Blocked by: "))
285 fmt.Fprintln(out, blockedBy)
286 }
287 if blocking := formatLinkedIssueListWithTitle(issue.Blocking.Nodes); blocking != "" {
288 fmt.Fprint(out, cs.Bold("Blocking: "))
289 fmt.Fprintln(out, blocking)
290 }
291 if projects := issueProjectList(*issue); projects != "" {
292 fmt.Fprint(out, cs.Bold("Projects: "))
293 fmt.Fprintln(out, projects)
294 }
295 if issue.Milestone != nil {
296 fmt.Fprint(out, cs.Bold("Milestone: "))
297 fmt.Fprintln(out, issue.Milestone.Title)

Callers 1

viewRunFunction · 0.85

Calls 15

FullNameFunction · 0.92
FuzzyAgoFunction · 0.92
PluralizeFunction · 0.92
RenderFunction · 0.92
WithThemeFunction · 0.92
WithWrapFunction · 0.92
issueStateTitleWithColorFunction · 0.85
issueAssigneeListFunction · 0.85
formatLinkedIssueRefFunction · 0.85
issueProjectListFunction · 0.85
ColorSchemeMethod · 0.80

Tested by

no test coverage detected