github.com/jasonish/buffalo@v0.8.2-0.20170413145823-bacbdd415f1b/buffalo/cmd/root.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  var cfgFile string
    11  
    12  // RootCmd is the hook for all of the other commands in the buffalo binary.
    13  var RootCmd = &cobra.Command{
    14  	SilenceErrors: true,
    15  	Use:           "buffalo",
    16  	Short:         "Helps you build your Buffalo applications that much easier!",
    17  	PersistentPreRun: func(cmd *cobra.Command, args []string) {
    18  		fmt.Printf("Buffalo version %s\n\n", Version)
    19  	},
    20  }
    21  
    22  // Execute adds all child commands to the root command sets flags appropriately.
    23  // This is called by main.main(). It only needs to happen once to the rootCmd.
    24  func Execute() {
    25  	if err := RootCmd.Execute(); err != nil {
    26  		fmt.Printf("Error: %s\n\n", err)
    27  		os.Exit(-1)
    28  	}
    29  }
    30  
    31  // func init() {
    32  // cobra.OnInitialize(initConfig)
    33  // RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.buffalo.yaml)")
    34  // }
    35  
    36  // func initConfig() {
    37  // 	if cfgFile != "" { // enable ability to specify config file via flag
    38  // 		viper.SetConfigFile(cfgFile)
    39  // 	}
    40  //
    41  // 	viper.SetConfigName(".buffalo") // name of config file (without extension)
    42  // 	viper.AddConfigPath("$HOME")    // adding home directory as first search path
    43  // 	viper.AutomaticEnv()            // read in environment variables that match
    44  //
    45  // 	// If a config file is found, read it in.
    46  // 	if err := viper.ReadInConfig(); err == nil {
    47  // 		fmt.Println("Using config file:", viper.ConfigFileUsed())
    48  // 	}
    49  // }