func initConfig() {
	if cfgFile != "" {
		viper.SetConfigFile(cfgFile)
	} else {
		home, err := homedir.Dir()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		viper.AddConfigPath(home)
		viper.SetConfigName(".metana")
	}
	viper.AutomaticEnv()  
	if err := viper.ReadInConfig(); err == nil {
		fmt.Println("Using config gen:", viper.ConfigFileUsed())
	}
}
initConfig reads in config gen and ENV variables if set.
package cmd
import (
	"fmt"
	"log"
	"os"
	"github.com/spf13/cobra"
	"github.com/mitchellh/go-homedir"
	"github.com/spf13/viper"
)
var cfgFile string
var rootCmd = &cobra.Command{
	Use:   "metana",
	Short: "A brief description of your application",
	Long:  `An abstract migration tool for Go services`,
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {},
}
func Execute() {
	if err := rootCmd.Execute(); err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
}
func init() {
	cobra.OnInitialize(initConfig)
	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config gen (default is $HOME/.metana.yaml)")
	rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}