Ported options codegen to cue

This commit is contained in:
Denis Arh
2022-01-29 12:18:00 +01:00
parent cb34bad61a
commit a035e6106f
100 changed files with 2471 additions and 2518 deletions
-39
View File
@@ -1,39 +0,0 @@
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
{{- range .Definitions }}
// - {{ .Source }}
{{- end }}
include::ROOT:partial$variables.adoc[]
{{ range .Definitions }}
= {{ .Docs.Title }}
{{ if .Docs.Intro }}
{{ .Docs.Intro }}
{{ end }}
{{- range .Properties }}
== *{{ toUpper .Env }}*
=== Type
`{{ .Type }}`
{{ if or .Default .Description -}}
{{ if .Default -}}
=== Default
[source]
----
{{ .Default }}
----
{{ end -}}
{{ if .Description -}}
=== Description
{{ .Description }}
{{ end -}}{{ end -}}
{{ end }}{{ end }}
-48
View File
@@ -1,48 +0,0 @@
package {{ .Package }}
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// {{ .Source }}
{{ if $.Imports -}}
import (
{{- range .Imports }}
{{ normalizeImport . }}
{{- end }}
){{ end }}
type (
{{ export $.Name }}Opt struct {
{{- range $prop := $.Properties}}
{{ export $prop.Name }} {{ $prop.Type }} `env:"{{ toUpper $prop.Env}}"`
{{- end }}
}
)
// {{ export $.Name }} initializes and returns a {{ export $.Name }}Opt with default values
func {{ export $.Name }}() (o *{{ export $.Name }}Opt) {
o = &{{ export $.Name }}Opt{
{{- range $prop := $.Properties }}
{{- if $prop.Default }}
{{ export $prop.Name }}: {{ $prop.Default }},
{{- end }}
{{- end }}
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *{{ export $.Name}}) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}