forked from alexandrst88/terraform-variables-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (39 loc) · 1021 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
package main
import (
"log"
"os"
"sort"
"github.com/hanks/terraform-variables-generator/cmd"
c "github.com/hanks/terraform-variables-generator/configs"
"github.com/hanks/terraform-variables-generator/version"
"github.com/urfave/cli"
)
func createApp() *cli.App {
app := cli.NewApp()
app.Name = "terraform-variables-genrator"
app.UsageText = "tfvargen [--config|-c vars.toml] [targetDir]"
app.Usage = "Simple Tool to Generate Variables file from Terraform Configuration."
app.Version = version.Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: c.VarConfName,
Usage: "`CONF_NAME` to customize generated variables.tf, will search in working directory",
},
}
sort.Sort(cli.FlagsByName(app.Flags))
app.Action = func(c *cli.Context) error {
targetDir := c.Args().Get(0)
conf := c.String("config")
cmd.Generate(targetDir, conf)
return nil
}
return app
}
func main() {
app := createApp()
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}