simplify options handling

This commit is contained in:
2021-10-31 23:07:12 +01:00
parent 27e82c8529
commit a68e3e426e
2 changed files with 15 additions and 8 deletions

View File

@@ -55,6 +55,7 @@ func GetConfig() *Config {
config = &Config{}
if err := viper.UnmarshalExact(config); err != nil {
colors.Error.Println(err)
colors.Error.Println("Could not parse config file!")
lock.Unlock()
os.Exit(1)
@@ -273,3 +274,15 @@ func getOptions(options Options, key string) []string {
}
return selected
}
func combineOptions(key string, l Location, b Backend) []string {
// Priority: location > backend > global
var options []string
gFlags := getOptions(GetConfig().Global, key)
bFlags := getOptions(b.Options, key)
lFlags := getOptions(l.Options, key)
options = append(options, gFlags...)
options = append(options, bFlags...)
options = append(options, lFlags...)
return options
}