schema

package
v0.0.0-...-951143b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCode_SchemaDSLParseFailed = "schema-dsl-parse-failed"
	ErrCode_SchemaParseFailed    = "scheam-parse-failed"
	ErrCode_SchemaCompileFailed  = "schema-compile-failed"
)

Variables

View Source
var Cmd_Schema = &cli.Command{
	Name:     "schema",
	Category: "Advanced",
	Usage:    "Manipulate schemas -- parsing, compiling, transforming, and storing.",
	Subcommands: []*cli.Command{{
		Name:  "parse",
		Usage: "Parse a schema DSL document, and produce the DMT form, emitted in JSON by default.",
		Flags: []cli.Flag{
			&cli.BoolFlag{
				Name:  "no-compile",
				Usage: `Skip the compilation phase, and just emit the DMT (regardless of whether it's logically valid).`,
			},
			&cli.BoolFlag{
				Name:  "save",
				Usage: `Put the parsed schema into storage, and return a CID pointing to it.  (Roughly equivalent to piping the schema parse command into a put command.)`,
			},
			&cli.StringFlag{
				Name:        "output",
				Usage:       `Defines what format the DMT should be produced in.  Valid arguments are codecs, specified as the word "codec:" followed by a multicodec name, or "codec:0x" followed by a multicodec indicator number in hexidecimal.`,
				DefaultText: "codec:json",
			},
		},
		Action: Action_SchemaParse,
	}, {
		Name:  "compile",
		Usage: "Compile a schema DMT document, exiting nonzero and reporting errors if anything is logically invalid.",
	}, {
		Name:  "codegen",
		Usage: "Generate code for working with IPLD schemas",
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:     "generator",
				Usage:    "Generator to be used for creating the code. Currently supports (go-gengo, go-bindnode)",
				Required: true,
			},
			&cli.PathFlag{
				Name:  "output",
				Usage: "Directory where the codegen files should be output to",
				Value: "ipldsch",
			},
			&cli.StringFlag{
				Name:  "package",
				Usage: "Package name for generated files",
				Value: "ipldsch",
			},
		},
		Action: Action_GoCodegen,
	}},
}

Functions

func Action_GoCodegen

func Action_GoCodegen(args *cli.Context) error

func Action_SchemaParse

func Action_SchemaParse(args *cli.Context) error

Action_SchemaParse is the function that implements the `ipld schema parse` subcommand's behaviors.

Errors:

  • ipldtool-error-invalid-args -- for incomprehensible or invalid arguments.
  • schema-dsl-parse-failed -- if the DSL document didn't parse.
  • schema-compile-failed -- if the schema was parsed, but was logically invalid.

func DSLParse

func DSLParse(inputName string, input io.Reader) (*schemadmt.Schema, error)

DSLParse is just the `schemadsl.Parse` feature, but wrapped in error tagging.

Errors:

  • schema-dsl-parse-failed -- if the DSL document didn't parse.

func SchemaCompile

func SchemaCompile(dmt *schemadmt.Schema) (*schema.TypeSystem, error)

DSLParse is just the `schemadmt.Compile` feature, but wrapped in error tagging.

Errors:

  • schema-compile-failed -- if the DSL document didn't parse.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL