how to handle decoding?

This commit is contained in:
adlerhurst
2025-02-17 08:56:33 +01:00
parent 308bcda8a0
commit 304e5823b2
2 changed files with 8 additions and 3 deletions

View File

@@ -84,11 +84,14 @@ func setField(field Updater, fields map[string]any, depth int) {
Label: fmt.Sprintf("Select one of %s: (%s)", f.Name(), f.Describe()), Label: fmt.Sprintf("Select one of %s: (%s)", f.Name(), f.Describe()),
Items: possibilities, Items: possibilities,
} }
i, _, err := prompt.Run() i, value, err := prompt.Run()
if err != nil { if err != nil {
fmt.Println("panic", err)
panic(err) panic(err)
} }
setField(f.Fields()[i], fields, depth+1) fv := fields[value]
// TODO: fv is result of decoder (postgres.config in this case)
setField(f.Fields()[i], fv.(map[string]any), depth+1)
} }
} }

View File

@@ -43,7 +43,9 @@ func DecodeConfig(_ string, config any) (database.Connector, error) {
} }
return &Config{config}, nil return &Config{config}, nil
case map[string]any: case map[string]any:
return nil, errors.New("map configuration not implemented") return &Config{
Config: &pgxpool.Config{},
}, nil
} }
return nil, errors.New("invalid configuration") return nil, errors.New("invalid configuration")
} }