-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
75 lines (63 loc) · 1.48 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/terrable-dev/terrable/config"
"github.com/terrable-dev/terrable/offline"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "terrable",
Version: buildInfo()["version"],
Commands: []*cli.Command{
{
Name: "offline",
Usage: "",
Action: func(cCtx *cli.Context) error {
tomlConfig, _ := config.ParseTerrableToml()
filePath := cCtx.String("file")
moduleName := cCtx.String("module")
port := cCtx.String("port")
if filePath == "" {
filePath = tomlConfig.Offline.File
}
if moduleName == "" {
moduleName = tomlConfig.Offline.Module
}
if port == "" {
port = tomlConfig.Offline.Port
}
err := offline.Run(filePath, moduleName, port)
if err != nil {
return err
}
return nil
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "file",
Aliases: []string{"f"},
Required: false,
Usage: "Path to the Terraform file",
},
&cli.StringFlag{
Name: "module",
Aliases: []string{"m"},
Required: false,
Usage: "Name of the terraform module to try and run locally",
},
&cli.StringFlag{
Name: "port",
Aliases: []string{"p"},
Required: false,
Usage: "The port number that the local instance of the API should listen for requests at",
},
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}