From a4a6dea5968dc810688eff478db1f4c600156f20 Mon Sep 17 00:00:00 2001 From: rsteube Date: Mon, 18 Jul 2022 18:26:34 +0200 Subject: [PATCH] tmp --- carapace.go | 2 +- internal/config/config.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/carapace.go b/carapace.go index 6237e7ebc..f9edde132 100644 --- a/carapace.go +++ b/carapace.go @@ -243,7 +243,7 @@ func addCompletionCommand(cmd *cobra.Command) { Run: func(cmd *cobra.Command, args []string) { for _, arg := range args { if splitted := strings.SplitN(arg, "=", 2); len(splitted) == 2 { - if err := style.Set(splitted[0], splitted[1]); err != nil { + if err := config.SetConfig(splitted[0], splitted[1]); err != nil { fmt.Fprint(cmd.ErrOrStderr(), err.Error()) } } else { diff --git a/internal/config/config.go b/internal/config/config.go index 4bf2fe661..de7fd8625 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -61,6 +61,11 @@ func Load() error { if err := load("styles", config.Styles); err != nil { return err } + + // TODO duplicated, ok or improve? + if err := load("configs", config.Configs); err != nil { + return err + } return nil } @@ -84,7 +89,7 @@ func load(name string, c configMap) error { elem := reflect.ValueOf(s).Elem() for k, v := range value { if field := elem.FieldByName(k); field != (reflect.Value{}) { - field.Set(reflect.ValueOf(v)) + field.Set(reflect.ValueOf(v).Convert(field.Type())) } } }