Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 18, 2022
1 parent c6c1d68 commit a4a6dea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion carapace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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()))
}
}
}
Expand Down

0 comments on commit a4a6dea

Please sign in to comment.