This commit is contained in:
maddalax 2024-09-13 16:24:56 -05:00
parent c41f2efec7
commit 86b6a0d52b
2 changed files with 15 additions and 18 deletions

View file

@ -1,7 +1,7 @@
package main
import (
"bufio"
"flag"
"fmt"
"os"
"os/exec"
@ -41,22 +41,23 @@ func deleteAllExceptTemplate(outPath string, excludeDir string) {
func main() {
cwd, _ := os.Getwd()
var outPath string
reader := bufio.NewReader(os.Stdin)
fmt.Print("What should we call your new app? Enter name: ")
outPath, _ = reader.ReadString('\n')
outPath = strings.ReplaceAll(outPath, "\n", "")
outPath = strings.ReplaceAll(outPath, " ", "-")
outPath = strings.ToLower(outPath)
if outPath == "" {
outPath := flag.String("out", "", "Specify the output path for the new app")
flag.Parse()
*outPath = strings.ReplaceAll(*outPath, "\n", "")
*outPath = strings.ReplaceAll(*outPath, " ", "-")
*outPath = strings.ToLower(*outPath)
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)
install := exec.Command("git", "clone", "https://github.com/maddalax/mhtml", "--depth=1", *outPath)
install.Stdout = os.Stdout
install.Stderr = os.Stderr
err := install.Run()
@ -66,9 +67,9 @@ func main() {
return
}
deleteAllExceptTemplate(outPath, excludeDir)
deleteAllExceptTemplate(*outPath, excludeDir)
newDir := filepath.Join(cwd, outPath)
newDir := filepath.Join(cwd, *outPath)
mvCmd := exec.Command("cp", "-vaR", fmt.Sprintf("%s/.", excludeDir), ".")
mvCmd.Dir = newDir

View file

@ -4,15 +4,11 @@ interval: 500ms
tasks:
template2:
template:
dir: '{{.USER_WORKING_DIR}}'
desc: Generate template from source code
cmds:
- |
echo "Type value of FOO:"
read FOO;
echo "You said: ${FOO}";
- go run github.com/maddalax/mhtml/framework/tooling/downloadtemplate@latest
- go run github.com/maddalax/mhtml/framework/tooling/downloadtemplate@latest -out my-app
setup:
deps: [copy-framework-assets, ast]