-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
75 lines (66 loc) · 1.35 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
66
67
68
69
70
71
72
73
74
75
package main
import (
"log"
"os"
"github.com/jackofallops/tfpdk/commands"
"github.com/mitchellh/cli"
)
var Commands map[string]cli.CommandFactory
func main() {
os.Exit(realMain(os.Args[1:]))
}
func realMain(args []string) int {
var ui cli.Ui = &cli.ColoredUi{
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
InfoColor: cli.UiColorNone,
Ui: &cli.BasicUi{
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
},
}
Commands = map[string]cli.CommandFactory{
"init": func() (cli.Command, error) {
return &commands.InitialiseCommand{
Ui: ui,
}, nil
},
"resource": func() (cli.Command, error) {
return &commands.ResourceCommand{
Ui: ui,
}, nil
},
"datasource": func() (cli.Command, error) {
return &commands.DataSourceCommand{
Ui: ui,
}, nil
},
"document": func() (cli.Command, error) {
return &commands.DocumentCommand{
Ui: ui,
}, nil
},
"config": func() (cli.Command, error) {
return &commands.GenConfigCommand{
Ui: ui,
}, nil
},
"servicepackage": func() (cli.Command, error) {
return &commands.ServicePackageCommand{
Ui: ui,
}, nil
},
}
tfpdk := cli.CLI{
Args: args,
Commands: Commands,
Name: "tfpdk",
Version: "0.1.0",
}
exitStatus, err := tfpdk.Run()
if err != nil {
log.Println(err)
}
return exitStatus
}