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