-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
31 lines (26 loc) · 771 Bytes
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cmd
import (
"log"
"os"
"path"
"github.com/spf13/cobra"
)
const RESOURCE_DIR="res"
const DIRECTORY_PERMISSIONS=0755
func onInit(cmd *cobra.Command, args []string) {
log.Println("Initializing environment")
if cwd, err := os.Getwd(); err == nil {
os.MkdirAll(path.Join(cwd, RESOURCE_DIR), DIRECTORY_PERMISSIONS)
os.MkdirAll(path.Join(cwd, RESOURCE_DIR, "views"), DIRECTORY_PERMISSIONS)
os.MkdirAll(path.Join(cwd, RESOURCE_DIR, "static"), DIRECTORY_PERMISSIONS)
log.Println("Environment is initialized")
log.Println("Execute the migration command next!")
} else {
log.Fatal(err)
}
}
var initCmd = &cobra.Command {
Use: "init",
Short: "Init application environment",
Run: onInit,
}