project

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GraphTemplates = []GraphTemplate{
		{
			Name:   "config",
			Format: "cmd/etc/app.yaml",
		},
		{
			Name:   "main",
			Format: "cmd/main.go",
		},
		{
			Name:   "mod",
			Format: "go.mod",
		},
		{
			Name:   "makefile",
			Format: "Makefile",
		},
		{
			Name:   "readme",
			Format: "README.md",
		},
		{
			Name:   "gitignore",
			Format: ".gitignore",
		},
	}
)
View Source
var InitCmd = &cli.Command{
	Name:  "init",
	Usage: "a tool for generate woocoo web code from OpenAPI 3 specifications",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "package",
			Aliases:  []string{"p"},
			Usage:    "the package name of the generated code",
			Required: true,
		},
		&cli.StringFlag{
			Name:     "target",
			Aliases:  []string{"t"},
			Usage:    "the target directory of the generated code",
			Required: true,
		},
		&cli.StringSliceFlag{
			Name:    "modules",
			Aliases: []string{"m"},
			Usage:   "the modules of the generated code",
		},
	},
	Action: func(c *cli.Context) (err error) {
		dir := c.String("target")

		fd, err := filepath.Abs(dir)
		if err != nil {
			return err
		}
		cfg := &Config{
			Package: c.String("package"),
			Target:  fd,
			Modules: c.StringSlice("modules"),
		}

		return generateWeb(cfg)
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Package        string `json:"package"`
	Target         string `json:"target,omitempty"`
	Templates      []*helper.Template
	Header         string   `json:"header,omitempty"`
	Modules        []string `json:"modules,omitempty"`
	SupportModules []string `json:"supportModules"`
}

func (Config) Imports

func (c Config) Imports() []string

type GenerateFunc

type GenerateFunc func(*Graph) error

The GenerateFunc type is an adapter to allow the use of ordinary function as Generator. If f is a function with the appropriate signature, GenerateFunc(f) is a Generator that calls f.

func (GenerateFunc) Generate

func (f GenerateFunc) Generate(g *Graph) error

type Generator

type Generator interface {
	// Generate generates the ent artifacts for the given graph.
	Generate(*Graph) error
}

type Graph

type Graph struct {
	*Config
	Mods []string
}

func NewGraph

func NewGraph(c *Config) (g *Graph, err error)

func (*Graph) Gen

func (g *Graph) Gen(gf GenerateFunc) error

Gen generates the artifacts for the graph.

func (*Graph) HasModule

func (g *Graph) HasModule(name string) bool

func (*Graph) HasStore

func (g *Graph) HasStore() bool

type GraphTemplate

type GraphTemplate struct {
	Name           string
	Format         string
	ExtendPatterns []string
}

Jump to

Keyboard shortcuts

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