MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / renderPlainStatusTable

Function renderPlainStatusTable

cmd/status_plain.go:14–58  ·  view source on GitHub ↗

renderPlainStatusTable prints a plain-text tab-aligned table of instances to stdout.

(instances []api.Instance, verbose bool)

Source from the content-addressed store, hash-verified

12
13// renderPlainStatusTable prints a plain-text tab-aligned table of instances to stdout.
14func renderPlainStatusTable(instances []api.Instance, verbose bool) {
15 if len(instances) == 0 {
16 fmt.Fprintln(os.Stderr, "No instances found.")
17 return
18 }
19
20 w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
21 fmt.Fprintln(w, "ID\tUUID\tSTATUS\tADDRESS\tDISK\tGPU\tvCPUs\tRAM\tTEMPLATE")
22
23 for _, inst := range instances {
24 gpu := fmt.Sprintf("%sx%s", inst.NumGPUs, utils.FormatGPUType(inst.GPUType))
25 disk := fmt.Sprintf("%dGB", inst.Storage)
26 ram := fmt.Sprintf("%sGB", inst.Memory)
27 fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
28 inst.ID,
29 inst.UUID,
30 inst.Status,
31 inst.GetIP(),
32 disk,
33 gpu,
34 inst.CPUCores,
35 ram,
36 inst.Template,
37 )
38 }
39 w.Flush()
40
41 // Print recent events if any
42 var hasEvents bool
43 for _, inst := range instances {
44 if inst.LastRestart == nil {
45 continue
46 }
47 if !verbose && time.Since(inst.LastRestart.Timestamp) > time.Hour {
48 continue
49 }
50 if !hasEvents {
51 fmt.Fprintln(os.Stdout, "\nRecent Events:")
52 hasEvents = true
53 }
54 ts := inst.LastRestart.Timestamp.Local().Format("2006-01-02_15:04:05.0000")
55 fmt.Fprintf(os.Stdout, " %s\n [%s]: %s — %s\n",
56 inst.Name, ts, inst.LastRestart.Reason, inst.LastRestart.Message)
57 }
58}
59
60// renderPlainSnapshotTable prints a plain-text tab-aligned table of snapshots to stdout.
61func renderPlainSnapshotTable(snapshots []api.Snapshot) {

Callers 1

RunStatusFunction · 0.85

Calls 2

FormatGPUTypeFunction · 0.92
GetIPMethod · 0.80

Tested by

no test coverage detected