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

Function printHumanIssuePreview

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

Source from the content-addressed store, hash-verified

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