From 99dea36a63e7bbfa8c02be93420b0314c0273e91 Mon Sep 17 00:00:00 2001 From: maddalax Date: Fri, 13 Sep 2024 15:56:03 -0500 Subject: [PATCH] test --- framework/tooling/downloadtemplate/main.go | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/framework/tooling/downloadtemplate/main.go b/framework/tooling/downloadtemplate/main.go index b1f610e..0dea044 100644 --- a/framework/tooling/downloadtemplate/main.go +++ b/framework/tooling/downloadtemplate/main.go @@ -38,7 +38,15 @@ func deleteAllExceptTemplate(outPath string, excludeDir string) { } func main() { - outPath := "new-app" + var outPath string + fmt.Print("What should we call your new app? ") + fmt.Scanln(&outPath) // Reads user input from the command line + + if outPath == "" { + fmt.Println("Please provide a name for your app.") + return + } + excludeDir := "starter-template" install := exec.Command("git", "clone", "https://github.com/maddalax/mhtml", "--depth=1", outPath) @@ -53,7 +61,21 @@ func main() { deleteAllExceptTemplate(outPath, excludeDir) - //exec.Command("mv", "starter-template/*", "./ 2>/dev/null && rmdir starter-template") + templateDir := filepath.Join(outPath, excludeDir) + + err = exec.Command("mv", templateDir+"/*", "./"+outPath).Run() + + if err != nil { + println("Error moving files %v\n", err) + return + } + + err = exec.Command("rm", "-rf", templateDir).Run() + + if err != nil { + println("Error removing directory %v\n", err) + return + } println("Template downloaded successfully!") }