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

Method footerView

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

Source from the content-addressed store, hash-verified

452}
453
454func (m *browseModel) footerView() string {
455 var footer string
456 switch {
457 case m.status != "":
458 footer = m.status
459 case m.readmeState == readmeLoading:
460 footer = "fetching readme..."
461 default:
462 var (
463 full = fmt.Sprintf(
464 "%s help %s move %s install %s remove %s web %s view readme %s quit",
465 m.colors.Bold("?"),
466 m.colors.Bold("j/k"),
467 m.colors.Bold("i"),
468 m.colors.Bold("r"),
469 m.colors.Bold("w"),
470 m.colors.Bold("enter"),
471 m.colors.Bold("q"),
472 )
473 compact = fmt.Sprintf(
474 "%s help %s move %s readme %s quit",
475 m.colors.Bold("?"),
476 m.colors.Bold("j/k"),
477 m.colors.Bold("enter"),
478 m.colors.Bold("q"),
479 )
480 minimal = fmt.Sprintf("%s help %s quit", m.colors.Bold("?"), m.colors.Bold("q"))
481 )
482 switch {
483 case m.width <= 0 || lipgloss.Width(full) <= m.width:
484 footer = full
485 case lipgloss.Width(compact) <= m.width:
486 footer = compact
487 default:
488 footer = minimal
489 }
490 }
491 if m.width <= 0 {
492 return footer
493 }
494 footer = wrapFooter(footer, m.width)
495 if m.height <= 0 {
496 return footer
497 }
498 lines := strings.Split(footer, "\n")
499 return strings.Join(lines[:min(len(lines), max(m.height-4, 1))], "\n")
500}
501
502func wrapFooter(footer string, width int) string {
503 var wrapped []string

Callers 2

ViewMethod · 0.95
mainHeightMethod · 0.95

Calls 3

wrapFooterFunction · 0.85
BoldMethod · 0.80
JoinMethod · 0.80

Tested by

no test coverage detected