-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
65 lines (56 loc) · 1.16 KB
/
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
60
61
62
63
64
65
package main
import (
"github.com/mitchellh/cli"
"log"
"os"
"runtime"
"wikible/command"
)
const APP_NAME = "wikible"
const APP_VERSION = "0.0.1"
func main() {
if os.Getenv("GOMAXPROCS") == "" {
runtime.GOMAXPROCS(runtime.NumCPU())
}
//code from https://github.com/hashicorp/terraform/blob/master/main.go#L40
os.Exit(realMain())
}
func realMain() int {
// CLI Creation
c := cli.NewCLI(APP_NAME, APP_VERSION)
c.Args = os.Args[1:]
c.HelpWriter = os.Stdout
// Commands Registration
c.Commands = map[string]cli.CommandFactory{
"plan": func() (cli.Command, error) {
return &command.PlanCommand{}, nil
},
"apply": func() (cli.Command, error) {
return &command.ApplyCommand{}, nil
},
"get": func() (cli.Command, error) {
return &command.GetCommand{}, nil
},
}
exitStatus, err := c.Run()
if err != nil {
log.Fatalln(err)
}
os.Exit(exitStatus)
return 0
}
func convert(i interface{}) interface{} {
switch x := i.(type) {
case map[interface{}]interface{}:
m2 := map[string]interface{}{}
for k, v := range x {
m2[k.(string)] = convert(v)
}
return m2
case []interface{}:
for i, v := range x {
x[i] = convert(v)
}
}
return i
}