-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
59 lines (47 loc) · 1008 Bytes
/
main.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
package main
import (
"github.com/Azer0s/Hummus/interpreter"
"github.com/Azer0s/Hummus/project"
"github.com/Azer0s/Hummus/runner"
log "github.com/sirupsen/logrus"
"os"
"path"
)
func init() {
p, err := os.Executable()
if err != nil {
panic(err)
}
interpreter.BasePath = path.Dir(p)
interpreter.LibBasePath = path.Join(interpreter.BasePath, "lib")
err = os.Mkdir(interpreter.LibBasePath, os.ModePerm)
if err != nil {
if !os.IsExist(err) {
log.Fatal(err.Error())
}
}
}
func main() {
if len(os.Args) > 1 {
if os.Args[1] == "init" {
project.InitProject(os.Args[2])
} else if os.Args[1] == "build" {
log.SetLevel(log.TraceLevel)
currentDir, err := os.Getwd()
if err != nil {
log.Fatal(err.Error())
}
project.BuildProject(currentDir)
} else if os.Args[1] == "run" {
currentDir, err := os.Getwd()
if err != nil {
panic(err)
}
project.RunProject(currentDir)
} else {
runner.RunFile(os.Args[1])
}
} else {
runner.RunRepl()
}
}