forked from cayleygraph/cayley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.go
42 lines (37 loc) · 826 Bytes
/
schema.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
42
package command
import (
"bytes"
"encoding/json"
"fmt"
"github.com/spf13/cobra"
"github.com/aperturerobotics/cayley/internal/linkedql/schema"
)
func NewSchemaCommand() *cobra.Command {
root := &cobra.Command{
Use: "schema",
Short: "Commands related to RDF schema",
}
root.AddCommand(
NewLinkedQLSchemaCommand(),
)
return root
}
func NewLinkedQLSchemaCommand() *cobra.Command {
return &cobra.Command{
Use: "linkedql",
Short: "Generate LinkedQL Schema to stdout",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
return fmt.Errorf("too many arguments provided, expected 0")
}
data := schema.Generate()
buf := bytes.NewBuffer(nil)
err := json.Indent(buf, data, "", "\t")
if err != nil {
return err
}
fmt.Println(buf)
return nil
},
}
}