package cli import ( "fmt" "os" "strings" "github.com/spf13/cobra" "github.com/spf13/viper" ) func RootCmd() *cobra.Command { cmd := &cobra.Command{ Use: "preflight", Short: "Run and retrieve preflight checks in a cluster", Long: `A preflight check is a set of validations that can and should be run to ensure that a cluster meets the requirements to run an application.`, SilenceUsage: true, } cobra.OnInitialize(initConfig) cmd.AddCommand(Run()) cmd.AddCommand(Server()) viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) return cmd } func InitAndExecute() { if err := RootCmd().Execute(); err != nil { fmt.Println(err) os.Exit(1) } } func initConfig() { viper.SetEnvPrefix("PREFLIGHT") viper.AutomaticEnv() }