package main import ( "fmt" "github.com/dballard/warren/lib/warren" "os" "os/exec" ) var deployUsage = ` warren deploy - Deploys the go server and support files ` var deployCmd = &Command{ Name: "deploy", Usage: "", Summary: "deploy the go server and support files", Help: deployUsage, Run: deployRun, } func checkDeployDir() string { _, err := os.Stat("deploy") if err != nil { os.Mkdir("deploy", os.ModeDir|0777) } githash := warren.GitHash() dst := "deploy/" + githash + "/" _, err = os.Stat(dst) if err != nil { os.Mkdir(dst, os.ModeDir|0777) } return dst } func getDeployFilesList() []string { name := warren.AppName() return []string{name} } func cp(dst, src string) error { return exec.Command("cp", src, dst, "-r").Run() } func deployRun(cmd *Command, args ...string) { if len(args) > 0 && args[0] == "help" { fmt.Print(cmd.Help) return } dst := checkDeployDir() fmt.Println(dst) files := getDeployFilesList() fmt.Println(files) for _, file := range files { cp(dst+file, file) } }