-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (59 loc) · 1.11 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
package main
import (
"fmt"
"os"
"os/exec"
"github.com/dex4er/tf/run"
)
var version = "dev"
var emptyStringsList = make([]string, 0)
func main() {
var err error
if len(os.Args) < 2 {
err = run.Help(emptyStringsList)
} else {
command := os.Args[1]
args := os.Args[2:]
switch command {
case "apply":
err = run.Apply(args)
case "destroy":
err = run.Destroy(args)
case "import":
err = run.Import(args)
case "init":
err = run.Init(args)
case "list":
err = run.List(args)
case "mv":
err = run.Mv(args)
case "plan":
err = run.Plan(args)
case "refresh":
err = run.Refresh(args)
case "rm":
err = run.Rm(args)
case "show":
err = run.Show(args)
case "taint":
err = run.Taint(args)
case "untaint":
err = run.Untaint(args)
case "upgrade":
err = run.Upgrade(args)
case "version":
err = run.Version(args, version)
default:
err = run.Terraform(command, args)
}
}
if err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
exitCode := exitError.ExitCode()
os.Exit(exitCode)
} else {
fmt.Println("Error:", err)
os.Exit(2)
}
}
}