-
Notifications
You must be signed in to change notification settings - Fork 0
/
jamf.go
93 lines (79 loc) · 1.65 KB
/
jamf.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"go/build"
"log"
"os"
"os/exec"
"path"
"github.com/urfave/cli"
"jamf/controllator"
"jamf/helper"
"jamf/initializer"
"jamf/modeler"
"jamf/modulator"
)
var gopath string
var boilerPath string
var binDir, _ = os.Executable()
var workDir, _ = os.Getwd()
var tempPath = path.Join("/tmp", "jamf")
var jamf = cli.NewApp()
func clearTemp() {
os.RemoveAll(tempPath)
helper.EnsureDirExists(tempPath)
}
func getGopath() {
gopath = os.Getenv("GOPATH")
if gopath == "" {
gopath = build.Default.GOPATH
}
boilerPath = path.Join(gopath, "bin", "jamfb")
}
func checkBoiler() {
exists := helper.DoesDirExist(boilerPath)
if !exists {
getBoiler()
}
}
func getBoiler() {
cmd := exec.Command("git", "clone", "https://github.com/LucHighwalker/norb.git", boilerPath)
err := cmd.Run()
if err != nil {
panic(err)
}
}
func info() {
jamf.Name = "Just Another Mvc Framework"
jamf.Usage = "It's just that."
author := cli.Author{Name: "Luc Highwalker", Email: "[email protected]"}
jamf.Authors = []*cli.Author{&author}
jamf.Version = "0.0.1"
}
func commands() {
jamf.Commands = []*cli.Command{
initializer.Command(binDir, boilerPath, tempPath, workDir),
modulator.Command(binDir, boilerPath, tempPath, workDir),
controllator.Command(workDir, tempPath),
modeler.Command(binDir, tempPath, workDir),
{
Name: "struct",
Aliases: []string{"s"},
Usage: "Generate a structure (model/controller).",
Action: func(c *cli.Context) error {
// Generate a model struct
return nil
},
},
}
}
func main() {
getGopath()
checkBoiler()
clearTemp()
info()
commands()
err := jamf.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}