Skip to content
Snippets Groups Projects
Commit db5e95db authored by Jose Carlos Luna Duran's avatar Jose Carlos Luna Duran
Browse files

Fixed other inputs than strings and arrays in config file

parent ff5bfbe8
No related branches found
No related tags found
No related merge requests found
......@@ -124,13 +124,15 @@ func bindFlags(cmd *cobra.Command) {
configName := f.Name
if !f.Changed && viper.IsSet(configName) {
val := viper.Get(configName)
if reflect.TypeOf(val).String() == "string" {
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", val))
} else { //Assume array of string
valType := reflect.TypeOf(val).String()
//support string arrays
if (valType == "[]interface {}") {
valArray := val.([]interface{})
for _, v := range valArray {
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", v))
}
} else { //Assume scalar
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", val))
}
}
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment