forked from joselitofilho/aws-terraform-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.go
54 lines (44 loc) · 1.39 KB
/
draw.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
package cmd
import (
"github.com/spf13/cobra"
"github.com/joselitofilho/aws-terraform-generator/internal/generators/draw"
)
// drawCmd represents the sqs command.
var drawCmd = &cobra.Command{
Use: "draw",
Short: "Manage Draw",
Run: func(cmd *cobra.Command, _ []string) {
workdirs, err := cmd.Flags().GetStringArray(flagWorkdir)
if err != nil {
printErrorAndExit(err)
}
files, err := cmd.Flags().GetStringArray(flagFile)
if err != nil {
printErrorAndExit(err)
}
configFilename, err := cmd.Flags().GetString(flagConfig)
if err != nil {
printErrorAndExit(err)
}
output, err := cmd.Flags().GetString(flagOutput)
if err != nil {
printErrorAndExit(err)
}
err = draw.NewDraw(workdirs, files, configFilename, output).Build()
if err != nil {
printErrorAndExit(err)
}
},
}
func init() {
rootCmd.AddCommand(drawCmd)
drawCmd.Flags().StringArrayP(flagWorkdir, "", []string{"."},
"Path to the folder where the terraform files are. For example: ./workdir")
drawCmd.Flags().StringArrayP(flagFile, "", nil,
"Path to the specific terraform file. For example: ./workdir/sqs.tf")
drawCmd.Flags().StringP(flagConfig, "c", "",
"Path to the YAML config file. For example: ./draw.config.yaml")
drawCmd.Flags().StringP(flagOutput, "o", "", "Path to the output folder. For example: ./output")
_ = drawCmd.MarkFlagRequired(flagConfig)
_ = drawCmd.MarkFlagRequired(flagOutput)
}