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

Support arrays in config file

parent 097782af
Branches
Tags 0.2.1
No related merge requests found
......@@ -5,6 +5,7 @@ import (
"log"
"os"
"path"
"reflect"
"strings"
"github.com/spf13/cobra"
......@@ -123,7 +124,14 @@ func bindFlags(cmd *cobra.Command) {
configName := f.Name
if !f.Changed && viper.IsSet(configName) {
val := viper.Get(configName)
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", val))
if reflect.TypeOf(val).String() == "string" {
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", val))
} else { //Assume array of string
valArray := val.([]interface{})
for _, v := range valArray {
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", v))
}
}
}
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment