| 32 | } |
| 33 | |
| 34 | func RunStatus() error { |
| 35 | client, err := getAuthenticatedClient() |
| 36 | if err != nil { |
| 37 | return err |
| 38 | } |
| 39 | monitoring := !noWait |
| 40 | interactive := tui.IsInteractive() && !JSONOutput |
| 41 | |
| 42 | // Auto-disable monitoring in non-interactive mode |
| 43 | if monitoring && !interactive { |
| 44 | monitoring = false |
| 45 | } |
| 46 | |
| 47 | var instances []api.Instance |
| 48 | if err := tui.RunWithBusySpinner("Fetching instances...", os.Stdout, func() error { |
| 49 | var e error |
| 50 | instances, e = client.ListInstances() |
| 51 | return e |
| 52 | }); err != nil { |
| 53 | return fmt.Errorf("failed to fetch instances: %w", err) |
| 54 | } |
| 55 | |
| 56 | if JSONOutput { |
| 57 | printJSON(instances) |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | if !interactive { |
| 62 | renderPlainStatusTable(instances, verboseStatus) |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | return tui.RunStatus(client, monitoring, instances, verboseStatus) |
| 67 | } |