Rewrote generators to use plugin system with default plugins

This commit is contained in:
David Allen 2024-06-19 14:19:42 -06:00
parent 8036a5a8c0
commit d77a31c7fe
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
15 changed files with 712 additions and 179 deletions

37
internal/util/params.go Normal file
View file

@ -0,0 +1,37 @@
package util
import (
"slices"
"golang.org/x/exp/maps"
)
type Params = map[string]any
type Option func(Params)
func GetParams(opts ...Option) Params {
params := Params{}
for _, opt := range opts {
opt(params)
}
return params
}
func OptionExists(params Params, opt string) bool {
var k []string = maps.Keys(params)
return slices.Contains(k, opt)
}
// Assert that the options exists within the params map
func AssertOptionsExist(params Params, opts ...string) []string {
foundKeys := []string{}
for k := range params {
index := slices.IndexFunc(opts, func(s string) bool {
return s == k
})
if index >= 0 {
foundKeys = append(foundKeys, k)
}
}
return foundKeys
}