@@ -10,27 +10,60 @@ import (
10
10
)
11
11
12
12
var (
13
+ primaryColor = lipgloss .Color ("#8BE9FD" )
14
+ successColor = lipgloss .Color ("#50FA7B" )
15
+ errorColor = lipgloss .Color ("#FF5555" )
16
+ warningColor = lipgloss .Color ("#FFB86C" )
17
+ secondaryColor = lipgloss .Color ("#BD93F9" )
18
+ textColor = lipgloss .Color ("#F8F8F2" )
19
+
13
20
styleTitle = lipgloss .NewStyle ().
14
21
Bold (true ).
15
- Foreground (lipgloss .Color ("#FF6B6B" )).
16
- MarginBottom (1 )
22
+ Foreground (primaryColor ).
23
+ MarginBottom (1 ).
24
+ BorderStyle (lipgloss .RoundedBorder ()).
25
+ Padding (0 , 1 ).
26
+ Align (lipgloss .Center )
17
27
18
28
styleSuccess = lipgloss .NewStyle ().
19
- Foreground (lipgloss .Color ("#59CD90" ))
29
+ Foreground (successColor ).
30
+ Bold (true ).
31
+ PaddingLeft (2 )
20
32
21
33
styleError = lipgloss .NewStyle ().
22
- Foreground (lipgloss .Color ("#FF6B6B" ))
34
+ Foreground (errorColor ).
35
+ Bold (true ).
36
+ PaddingLeft (2 )
23
37
24
38
styleProgress = lipgloss .NewStyle ().
25
- Foreground (lipgloss .Color ("#4ECDC4" ))
39
+ Foreground (secondaryColor ).
40
+ PaddingLeft (2 )
26
41
27
42
styleCompleted = lipgloss .NewStyle ().
28
- Foreground (lipgloss .Color ("#59CD90" )).
29
- SetString ("✓" )
43
+ Foreground (successColor ).
44
+ SetString ("✓" ).
45
+ PaddingRight (1 )
30
46
31
47
stylePending = lipgloss .NewStyle ().
32
- Foreground (lipgloss .Color ("#FFD93D" )).
33
- SetString ("•" )
48
+ Foreground (warningColor ).
49
+ SetString ("•" ).
50
+ PaddingRight (1 )
51
+
52
+ styleCurrentStep = lipgloss .NewStyle ().
53
+ Foreground (primaryColor ).
54
+ Bold (true )
55
+
56
+ styleCompletedStep = lipgloss .NewStyle ().
57
+ Foreground (textColor ).
58
+ Faint (true )
59
+
60
+ stylePendingStep = lipgloss .NewStyle ().
61
+ Foreground (textColor ).
62
+ Faint (true )
63
+
64
+ styleStepMessage = lipgloss .NewStyle ().
65
+ Foreground (secondaryColor ).
66
+ Italic (true )
34
67
)
35
68
36
69
type InstallationStep struct {
@@ -163,7 +196,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
163
196
case tea.KeyMsg :
164
197
if msg .Type == tea .KeyCtrlC {
165
198
m .cancelled = true
166
- return m , tea .Quit
199
+ return m , tea .Sequence (
200
+ tea .Println (styleError .Render ("Installation cancelled by user" )),
201
+ tea .Quit ,
202
+ )
167
203
}
168
204
169
205
case spinner.TickMsg :
@@ -178,67 +214,82 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
178
214
return m , m .runNextStep ()
179
215
}
180
216
m .completed = true
181
- return m , tea .Quit
217
+ return m , tea .Sequence (
218
+ tea .Println (styleSuccess .Render ("✨ Cursor installation completed successfully! ✨" )),
219
+ tea .Quit ,
220
+ )
182
221
183
222
case errMsg :
184
223
m .err = msg
185
- return m , tea .Quit
224
+ return m , tea .Sequence (
225
+ tea .Println (styleError .Render (fmt .Sprintf ("Error: %v" , m .err ))),
226
+ tea .Quit ,
227
+ )
186
228
187
229
case upToDateMsg :
188
230
m .upToDate = true
189
231
m .currentVersion = msg .version
190
- return m , tea .Quit
232
+ return m , tea .Sequence (
233
+ tea .Println (styleSuccess .Render ("✨ Cursor " + m .currentVersion + " is already installed and up to date! ✨" )),
234
+ tea .Quit ,
235
+ )
191
236
192
237
case doneMsg :
193
238
m .completed = true
194
- return m , tea .Quit
239
+ return m , tea .Sequence (
240
+ tea .Println (styleSuccess .Render ("✨ Cursor installation completed successfully! ✨" )),
241
+ tea .Quit ,
242
+ )
195
243
}
196
244
197
245
return m , nil
198
246
}
199
247
200
248
func (m model ) View () string {
201
249
if m .cancelled {
202
- return styleError .Render ("Installation cancelled by user. \n " )
250
+ return styleError .Render ("✗ Installation cancelled by user" )
203
251
}
204
252
205
253
if m .upToDate {
206
- return styleSuccess .Render (fmt .Sprintf ("✨ Cursor is already up to date (version %s)! ✨ \n " , m .currentVersion ))
254
+ return styleSuccess .Render (fmt .Sprintf ("✨ Cursor is already up to date (version %s)!" , m .currentVersion ))
207
255
}
208
256
209
257
if m .completed {
210
- return styleSuccess .Render ("✨ Cursor installation completed successfully! ✨ \n " )
258
+ return styleSuccess .Render ("✨ Cursor installation completed successfully!" )
211
259
}
212
260
213
261
if m .err != nil {
214
- return styleError .Render (fmt .Sprintf ("Error: %v\n " , m .err ))
262
+ return styleError .Render (fmt .Sprintf ("✗ Error: %v" , m .err ))
215
263
}
216
264
217
265
var s string
218
- s += styleTitle .Render ("Cursor Installer" ) + "\n "
219
- s += styleProgress .Render (fmt .Sprintf ("Progress: %d/%d" , m .currentStep , len (m .steps ))) + "\n "
266
+
267
+ s += styleTitle .Render ("Cursor Installer" ) + "\n \n "
268
+
269
+ progress := fmt .Sprintf ("Step %d of %d" , m .currentStep + 1 , len (m .steps ))
270
+ s += styleProgress .Render (progress ) + "\n \n "
220
271
221
272
for i , step := range m .steps {
222
273
var stepPrefix string
274
+ var stepStyle lipgloss.Style
275
+
223
276
if i < m .currentStep {
224
277
stepPrefix = styleCompleted .String ()
278
+ stepStyle = styleCompletedStep
225
279
} else if i == m .currentStep {
226
280
stepPrefix = m .spinner .View ()
281
+ stepStyle = styleCurrentStep
227
282
} else {
228
283
stepPrefix = stylePending .String ()
284
+ stepStyle = stylePendingStep
229
285
}
230
286
231
- stepStyle := lipgloss .NewStyle ()
232
- if i == m .currentStep {
233
- stepStyle = stepStyle .Foreground (lipgloss .Color ("#4ECDC4" ))
234
- } else if i < m .currentStep {
235
- stepStyle = stepStyle .Foreground (lipgloss .Color ("#59CD90" ))
236
- }
287
+ s += fmt .Sprintf ("%s%s" , stepPrefix , stepStyle .Render (step .name ))
237
288
238
- s += fmt .Sprintf ("%s %s" , stepPrefix , stepStyle .Render (step .name ))
239
289
if i == m .currentStep {
240
- s += fmt .Sprintf (": %s" , step .message )
290
+ s += styleStepMessage . Render ( fmt .Sprintf (": %s" , step .message ) )
241
291
}
292
+
242
293
s += "\n "
243
294
}
244
295
0 commit comments