Home

cuesonnet @main - refs - log -
-
https://git.jolheiser.com/cuesonnet.git
CUE + Jsonnet
tree log patch
a very basic CLI Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQMYB4oCEnHvLY29eMZhM5FjD6Z8JvIfp/RFAMSuOgCxjh0ZLcJAk0FJuzvKnR3kkhe gZQfaTp41kA7gh+XDPUg4= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
3 days ago
1 changed files, 35 additions(+), 0 deletions(-)
cmd/cuesonnet/main.go
I cmd/cuesonnet/main.go
 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
diff --git a/cmd/cuesonnet/main.go b/cmd/cuesonnet/main.go
new file mode 100644
index 0000000000000000000000000000000000000000..9f740d252ae58b771327748735258edabc22df11
--- /dev/null
+++ b/cmd/cuesonnet/main.go
@@ -0,0 +1,35 @@
+package main
+
+import (
+	"bytes"
+	"fmt"
+	"log"
+	"os"
+
+	"go.jolheiser.com/cuesonnet"
+)
+
+func maine() error {
+	args := os.Args[1:]
+	if len(args) < 2 {
+		log.Fatalln("cuesonnet <schema.cue> <data.jsonnet>")
+	}
+
+	schema, err := os.ReadFile(args[0])
+	if err != nil {
+		return fmt.Errorf("could not open schema: %w", err)
+	}
+
+	data, err := os.ReadFile(args[1])
+	if err != nil {
+		return fmt.Errorf("could not open data: %w", err)
+	}
+
+	return cuesonnet.Schema(string(schema)).Decode(bytes.NewReader(data), &map[string]any{})
+}
+
+func main() {
+	if err := maine(); err != nil {
+		log.Println(err)
+	}
+}