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

Function statusRun

pkg/cmd/status/status.go:634–753  ·  view source on GitHub ↗
(opts *StatusOptions)

Source from the content-addressed store, hash-verified

632}
633
634func statusRun(opts *StatusOptions) error {
635 client, err := opts.HttpClient()
636 if err != nil {
637 return fmt.Errorf("could not create client: %w", err)
638 }
639
640 hostname, _ := opts.HostConfig.DefaultHost()
641
642 sg := NewStatusGetter(client, hostname, opts)
643
644 // TODO break out sections into individual subcommands
645
646 g := new(errgroup.Group)
647 g.Go(func() error {
648 if err := sg.LoadNotifications(); err != nil {
649 return fmt.Errorf("could not load notifications: %w", err)
650 }
651 return nil
652 })
653 g.Go(func() error {
654 if err := sg.LoadEvents(); err != nil {
655 return fmt.Errorf("could not load events: %w", err)
656 }
657 return nil
658 })
659 g.Go(func() error {
660 if err := sg.LoadSearchResults(); err != nil {
661 return fmt.Errorf("failed to search: %w", err)
662 }
663 return nil
664 })
665
666 opts.IO.StartProgressIndicator()
667 err = g.Wait()
668 opts.IO.StopProgressIndicator()
669 if err != nil {
670 return err
671 }
672
673 cs := opts.IO.ColorScheme()
674 out := opts.IO.Out
675 fullWidth := opts.IO.TerminalWidth()
676 halfWidth := (fullWidth / 2) - 2
677
678 idStyle := cs.Cyan
679 leftHalfStyle := lipgloss.NewStyle().Width(halfWidth).Padding(0).MarginRight(1).BorderRight(true).BorderStyle(lipgloss.NormalBorder())
680 rightHalfStyle := lipgloss.NewStyle().Width(halfWidth).Padding(0)
681
682 section := func(header string, items []StatusItem, width, rowLimit int) (string, error) {
683 tableOut := &bytes.Buffer{}
684 fmt.Fprintln(tableOut, cs.Bold(header))
685 if len(items) == 0 {
686 fmt.Fprintln(tableOut, "Nothing here ^_^")
687 } else {
688 //nolint:staticcheck // SA1019: Headers distract from numerous nested tables.
689 tp := tableprinter.NewWithWriter(tableOut, opts.IO.IsStdoutTTY(), width, cs, tableprinter.NoHeader)
690 for i, si := range items {
691 if i == rowLimit {

Callers 2

NewCmdStatusFunction · 0.70
TestStatusRunFunction · 0.70

Calls 15

LoadNotificationsMethod · 0.95
LoadEventsMethod · 0.95
LoadSearchResultsMethod · 0.95
HasAuthErrorsMethod · 0.95
NewWithWriterFunction · 0.92
NewStatusGetterFunction · 0.85
ColorSchemeMethod · 0.80
TerminalWidthMethod · 0.80
BoldMethod · 0.80
IsStdoutTTYMethod · 0.80
PreviewMethod · 0.80
MutedfMethod · 0.80

Tested by 1

TestStatusRunFunction · 0.56