Fixed issue with generate and added some documentation to funcs

This commit is contained in:
David Allen 2024-07-08 16:11:10 -06:00
parent 7494468bed
commit cd840b2bf0
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
9 changed files with 219 additions and 158 deletions

View file

@ -6,9 +6,11 @@ import (
"golang.org/x/exp/maps"
)
type Params = map[string]any
// Params are accessible in generator.Generate().
type Params map[string]any
type Option func(Params)
// Extract all parameters from the options passed as map[string]any.
func GetParams(opts ...Option) Params {
params := Params{}
for _, opt := range opts {
@ -17,7 +19,8 @@ func GetParams(opts ...Option) Params {
return params
}
func OptionExists(params Params, opt string) bool {
// Test if an option is present in params
func (p *Params) OptionExists(params Params, opt string) bool {
var k []string = maps.Keys(params)
return slices.Contains(k, opt)
}