-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
39 lines (31 loc) · 756 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
package main
import (
"os"
"tfgen/cmd"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
var version string
var verbose bool
func init() {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
}
func main() {
cobra.OnInitialize(initConfig)
rootCmd := &cobra.Command{
Use: "tfgen",
Short: "tfgen is a devtool to keep your Terraform code consistent and DRY",
Version: version,
}
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
rootCmd.AddCommand(cmd.NewExecCmd())
rootCmd.AddCommand(cmd.NewCleanCmd())
rootCmd.Execute()
}
func initConfig() {
if verbose {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
}