-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
demo.cue
86 lines (67 loc) · 1.67 KB
/
demo.cue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package demo
import (
"github.com/hofstadter-io/hof/schema/gen"
)
// This is example usage of your generator
DemoExample: #DemoGenerator & {
@gen(demo)
// inputs to the generator
"users": users
"data": data
// other settings
Diff3: false
Outdir: "./"
// required by examples inside the same module
// your users do not set or see this field
PackageName: ""
}
// This is your reusable generator module
//
#DemoGenerator: gen.#Generator & {
//
// user input fields
//
// this is the interface for this generator module
// typically you enforce schema(s) here
users: _
data: _
//
// Internal Fields
//
// This is the global input data the templates will see
// You can reshape and transform the user inputs
// While we put it under internal, you can expose In
In: {
// if you want to user your input data
// add top-level fields from your
// CUE entrypoints here, adjusting as needed
// Since you made this a module for others,
// it won't output until this field is filled
"users": users
"data": data
...
}
// required for hof CUE modules to work
// your users do not set or see this field
PackageName: string | *"hof.io/demo"
// Templates: [{Globs: ["./templates/**/*"], TrimPrefix: "./templates/"}]
Templates: [ {Globs: [ "min.txt", "ext.txt"]}]
// Partials: [#Templates & {Globs: ["./partials/**/*"], TrimPrefix: "./partials/"}]
Partials: []
// The final list of files for hof to generate
Out: [...gen.#File] & [
t_0,
t_1,
]
// These are the -T mappings
t_0: {
TemplatePath: "min.txt"
Filepath: "out.txt"
}
t_1: {
TemplatePath: "ext.txt"
Filepath: "users.txt"
}
// so your users can build on this
...
}