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