@@ -156,7 +156,7 @@ func downloadTemplates(url string) error {
156
156
157
157
repoName , err := extractRepoNameFromURL (url )
158
158
if err != nil {
159
- return fmt .Errorf ("error extracting repository name: %v" , err )
159
+ return fmt .Errorf (color . RedString ( "Error: extracting repository name: %v") , err )
160
160
}
161
161
162
162
repoDir := repoDirectory
@@ -204,6 +204,17 @@ func deleteTemplateByName(templateName string) error {
204
204
}
205
205
206
206
func listTemplates () ([]string , error ) {
207
+
208
+ if _ , err := os .Stat (templatesDirectory ); os .IsNotExist (err ) {
209
+ if err := os .MkdirAll (templatesDirectory , 0755 ); err != nil {
210
+ return nil , fmt .Errorf (color .RedString ("Error: creating templates directory: %v" , err ))
211
+ }
212
+ if err := downloadTemplates (defaultTemplatesRepoURL ); err != nil {
213
+ return nil , err
214
+ }
215
+
216
+ }
217
+
207
218
var templates []string
208
219
209
220
files , err := os .ReadDir (templatesDirectory )
@@ -222,6 +233,7 @@ func listTemplates() ([]string, error) {
222
233
223
234
func selectTemplate (templates []string ) (string , error ) {
224
235
clearConsole ()
236
+ fmt .Print (color .CyanString (appNameArt ))
225
237
fmt .Println (color .YellowString ("Select a template:" ))
226
238
227
239
currentIndex := 0
@@ -245,18 +257,22 @@ func selectTemplate(templates []string) (string, error) {
245
257
if currentIndex > 0 {
246
258
currentIndex --
247
259
clearConsole ()
260
+ fmt .Print (color .CyanString (appNameArt ))
261
+
248
262
fmt .Println (color .YellowString ("Select a template:" ))
249
263
printTemplateOptions (templates , currentIndex )
250
264
}
251
265
case keyboard .KeyArrowDown :
252
266
if currentIndex < len (templates )- 1 {
253
267
currentIndex ++
254
268
clearConsole ()
269
+ fmt .Print (color .CyanString (appNameArt ))
255
270
fmt .Println (color .YellowString ("Select a template:" ))
256
271
printTemplateOptions (templates , currentIndex )
257
272
}
258
273
case keyboard .KeyEnter :
259
274
clearConsole ()
275
+ fmt .Print (color .CyanString (appNameArt ))
260
276
selectedTemplate := templates [currentIndex ]
261
277
return selectedTemplate , nil
262
278
case keyboard .KeyEsc :
0 commit comments