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

Function printHumanIssuePreview

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

Source from the content-addressed store, hash-verified

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