hexya-erp / hexya

Hexya business application development framework
http://hexya.io
Apache License 2.0
411 stars 125 forks source link

Config file was not read correctly. #2

Closed halybang closed 6 years ago

halybang commented 6 years ago

Run hexya -c config_file_name not work. Reason: Corbra parses command line args when call Execute() method. How to fix: Modify cmd/hexya.go

  1. In func init(), add cobra.OnInitialize(initConfig)
  2. Add function
    func initConfig() {
    cfgFile := viper.GetString("ConfigFileName")
    // Read config either from cfgFile or from home directory!
    viper.AddConfigPath("/etc/hexya/")
    viper.AddConfigPath("$HOME/.hexya")
    viper.AddConfigPath(".")
    if cfgFile == "" {
        cfgFile = "hexya"
    }
    viper.SetConfigFile(cfgFile)
    viper.ReadInConfig()
    }
npiganeau commented 6 years ago

You're right, this wasn't implemented.

Can you open a PR with your proposal ?