MCPcopy Create free account
hub / github.com/cli/cli / printHumanIssuePreview

Function printHumanIssuePreview

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

Source from the content-addressed store, hash-verified

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