config flags to config vars
This commit is contained in:
parent
c2252ba522
commit
4403059569
|
@ -51,9 +51,11 @@ func init() {
|
|||
cobra.OnInitialize(initConfig)
|
||||
|
||||
// Global flag
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sofad.yaml)")
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.sofad.yaml or the directory of the binary)")
|
||||
rootCmd.PersistentFlags().StringP("serverurl", "s", "", "The server url where the client will send the data to")
|
||||
rootCmd.PersistentFlags().StringP("privatekey", "k", "", "The locaton of the private key which will be used to authenticate against the server")
|
||||
viper.BindPFlag("server.serverurl", rootCmd.Flags().Lookup("serverurl"))
|
||||
rootCmd.PersistentFlags().StringP("privatekey", "k", "", "The location of the private key which will be used to authenticate against the server")
|
||||
viper.BindPFlag("server.privatekey", rootCmd.Flags().Lookup("privatekey"))
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
|
@ -69,7 +71,6 @@ func initConfig() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Search config in home directory with name ".cliend" (without extension).
|
||||
viper.AddConfigPath(home)
|
||||
viper.SetConfigName(".sofad")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user