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
+43
View File
@@ -0,0 +1,43 @@
package schema
import (
"strings"
)
#_ENV: =~ "^[A-Z][A-Z0-9_]*[A-Z0-9]?$"
//#_optName: =~ "^[a-zA-Z][a-zA-Z0-9\\s]*[a-zA-Z0-9]+$"
#optionsGroup: #_base & {
imports: [...string] | *([])
handle: #handle
title?: string
description?: string
env: #_ENV | *(strings.ToUpper(strings.Replace(handle, "-", "_", -1)))
_envPrefix: env
options: {
[_opt=_]: #option & {
handle: _opt
env: #_ENV | *(_envPrefix + "_" + strings.ToUpper(strings.Replace(handle, " ", "_", -1)))
}
}
}
#option: {
handle: #handle
_words: strings.Replace(strings.Replace(strings.Replace(handle, "-", " ", -1), "_", " ", -1), ".", " ", -1)
// lowercased (unexported, golang) identifier
ident: #ident | *strings.ToCamel(strings.Replace(strings.ToTitle(_words), " ", "", -1))
// upercased (exported, golang) identifier
expIdent: #expIdent | *strings.Replace(strings.ToTitle(_words), " ", "", -1)
type: string | *"string"
description?: string
default?: string
env?: #_ENV
}
+1 -1
View File
@@ -3,8 +3,8 @@ package schema
#platform: {
ident: #baseHandle | *"corteza"
options: [...#optionsGroup]
components: [...{platform: ident} & #component]
// env-var definitions
// options: {}
+1
View File
@@ -16,6 +16,7 @@ import (
// More liberal then identifier, allows underscores and dots
#baseHandle: =~"^[a-z][a-z0-9-]*[a-z0-9]+$"
#_base: {
// lowercase dash-separated words
// used to build ident and exported identifiers