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

Method View

tui/delete.go:145–246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143}
144
145func (m deleteModel) View() string {
146 if m.err != nil {
147 return errorStyleTUI.Render(fmt.Sprintf("✗ Error: %v\n", m.err))
148 }
149
150 if m.quitting {
151 return ""
152 }
153
154 if m.step == deleteStepComplete {
155 return ""
156 }
157
158 var s strings.Builder
159
160 s.WriteString(m.styles.Title.Render("⚡ Delete Thunder Compute Instance"))
161 s.WriteString("\n")
162
163 switch m.step {
164 case deleteStepSelect:
165 s.WriteString("Select an instance to delete:\n\n")
166
167 for i, instance := range m.instances {
168 cursor := " "
169 if m.cursor == i {
170 cursor = m.styles.Cursor.Render("▶ ")
171 }
172
173 // Determine status style
174 var statusStyle lipgloss.Style
175 statusSuffix := ""
176 switch instance.Status {
177 case "RUNNING":
178 statusStyle = SuccessStyle()
179 case "STARTING":
180 statusStyle = WarningStyle()
181 case "DELETING":
182 statusStyle = ErrorStyle()
183 statusSuffix = " (already deleting)"
184 default:
185 statusStyle = lipgloss.NewStyle()
186 }
187
188 idAndName := fmt.Sprintf("(%s) %s", instance.ID, instance.Name)
189 if m.cursor == i {
190 idAndName = m.styles.Selected.Render(idAndName)
191 }
192
193 statusText := statusStyle.Render(fmt.Sprintf("(%s)", instance.Status))
194 rest := fmt.Sprintf(" %s%s - %sx%s",
195 statusText,
196 statusSuffix,
197 instance.NumGPUs,
198 utils.FormatGPUType(instance.GPUType),
199 )
200
201 s.WriteString(fmt.Sprintf("%s%s%s\n", cursor, idAndName, rest))
202 }

Callers 1

ViewMethod · 0.45

Calls 5

FormatGPUTypeFunction · 0.92
CapitalizeFunction · 0.92
SuccessStyleFunction · 0.85
WarningStyleFunction · 0.85
ErrorStyleFunction · 0.85

Tested by

no test coverage detected