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

Method listView

pkg/cmd/extension/browse/model.go:518–559  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

516}
517
518func (m *browseModel) listView() string {
519 if len(m.filtered) == 0 {
520 return "no matching extensions"
521 }
522
523 lines := make([]string, 0, m.pageSize()*2)
524 pageSize := m.pageSize()
525 start := min((m.cursor/pageSize)*pageSize, max(len(m.filtered)-pageSize, 0))
526 end := min(start+pageSize, len(m.filtered))
527 for i := start; i < end; i++ {
528 entry := m.entries[m.filtered[i]]
529 prefix := " "
530 if i == m.cursor {
531 prefix = "> "
532 }
533 title := prefix + entry.FullName
534 switch {
535 case i == m.cursor:
536 if entry.Official {
537 title += " (official)"
538 }
539 if entry.Installed {
540 title += " (installed)"
541 }
542 title = lipgloss.NewStyle().Reverse(true).Render(title)
543 default:
544 title = m.colors.Bold(title)
545 if entry.Official {
546 title += " " + m.colors.Yellow("(official)")
547 }
548 if entry.Installed {
549 title += " " + m.colors.Green("(installed)")
550 }
551 }
552 lines = append(lines,
553 renderListLine(title, m.listWidth()),
554 renderListLine(" "+entry.Description(), m.listWidth()),
555 )
556 }
557
558 return strings.Join(lines, "\n")
559}
560
561func (m *browseModel) singleColumn() bool {
562 return m.opts.SingleColumn || (m.width > 0 && m.width < 100)

Calls 9

pageSizeMethod · 0.95
listWidthMethod · 0.95
renderListLineFunction · 0.85
BoldMethod · 0.80
YellowMethod · 0.80
GreenMethod · 0.80
DescriptionMethod · 0.80
JoinMethod · 0.80
RenderMethod · 0.65