func certsCmdPreRun(*cobra.Command, []string) {
	cnf.ModeViper.BindPFlags(certsCmd.Flags())
}
certsCmdPreRun sets up the flag bindings
package cmd
import (
	"bytes"
	"errors"
	"fmt"
	"go/build"
	"io/ioutil"
	"os"
	"os/exec"
	"path/filepath"
	"text/template"
	"github.com/BurntSushi/toml"
	"github.com/spf13/cobra"
)
var generateCmd = &cobra.Command{
	Use:     "gen",
	Short:   "Generate your migrations, certs and config files",
	Example: "abcweb gen migration add_users",
}
var migrationCmd = &cobra.Command{
	Use:   "migration <name> [flags]",
	Short: "Generate a migration file",
	Long: `Generate migration will generate a .sql migration file in your db/migrations directory.
This tool pipes out to mig: https: 
	Example: "abcweb gen migration add_users",
	RunE:    migrationCmdRun,
}
var configCmd = &cobra.Command{
	Use:     "config",
	Short:   "Generate fresh config files",
	Long:    "Generate fresh config files",
	Example: "abcweb gen config",
	RunE:    configCmdRun,
}
var certsCmd = &cobra.Command{
	Use:     "certs",
	Short:   "Generate fresh TLS certificates",
	Long:    "Generate fresh TLS certificates",
	Example: "abcweb gen certs",
	RunE:    certsCmdRun,
}
func init() {
	configCmd.Flags().BoolP("force", "f", false, "Overwrite files if they already exist")
	certsCmd.Flags().BoolP("force", "f", false, "Overwrite files if they already exist")
	RootCmd.AddCommand(generateCmd)
	migrationCmd.PreRun = migrationCmdPreRun
	configCmd.PreRun = configCmdPreRun
	certsCmd.PreRun = certsCmdPreRun
	generateCmd.AddCommand(migrationCmd)
	generateCmd.AddCommand(configCmd)
	generateCmd.AddCommand(certsCmd)
}
func migrationCmdPreRun(*cobra.Command, []string) {
	cnf.ModeViper.BindPFlags(migrationCmd.Flags())
}
func migrationCmdRun(cmd *cobra.Command, args []string) error {
	checkDep("mig")
	if len(args) == 0 || len(args[0]) == 0 {
		fmt.Println(`command requires a migration name argument`)
		os.Exit(1)
	}
	exc := exec.Command("mig", "create", args[0])
	exc.Dir = filepath.Join(cnf.AppPath, migrationsDirectory)
	out, err := exc.CombinedOutput()
	fmt.Print(string(out))
	return err
}
func configCmdPreRun(*cobra.Command, []string) {
	cnf.ModeViper.BindPFlags(configCmd.Flags())
}
func configCmdRun(cmd *cobra.Command, args []string) error {
	fmt.Println("Generating fresh config files...")
	cfg := &newConfig{}
	_, err := toml.DecodeFile(filepath.Join(cnf.AppPath, ".abcweb.toml"), cfg)
	if err == os.ErrNotExist {
		fmt.Println("warning: unable to find .abcweb.toml, so your config may need tweaking")
		cfg.DefaultEnv = "prod"
	} else if err != nil {
		return err
	}
	cfg.AppName = cnf.AppName
	cfg.AppEnvName = cnf.AppEnvName
	cfg.AppPath = cnf.AppPath
	err = genConfigFiles(cnf.AppPath, cfg, false, cnf.ModeViper.GetBool("force"))
	if err != nil {
		return err
	}
	fmt.Println("SUCCESS.")
	return nil
}