forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (33 loc) · 621 Bytes
/
main.go
File metadata and controls
36 lines (33 loc) · 621 Bytes
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
package main
import (
"bufio"
"io"
"os"
"github.com/kyleconroy/sqlc/internal/codegen/python"
"github.com/kyleconroy/sqlc/internal/plugin"
)
func main() {
var req plugin.CodeGenRequest
reqBlob, err := io.ReadAll(os.Stdin)
if err != nil {
os.Exit(10)
}
if err := req.UnmarshalVT(reqBlob); err != nil {
os.Exit(11)
}
resp, err := python.Generate(&req)
if err != nil {
os.Exit(12)
}
respBlob, err := resp.MarshalVT()
if err != nil {
os.Exit(13)
}
w := bufio.NewWriter(os.Stdout)
if _, err := w.Write(respBlob); err != nil {
os.Exit(14)
}
if err := w.Flush(); err != nil {
os.Exit(15)
}
}