| 634 | } |
| 635 | |
| 636 | func 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 { |