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

Function statusRun

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

Source from the content-addressed store, hash-verified

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