core

package
v0.0.0-...-fc4761b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputDirDepth

func OutputDirDepth(outFolder string) int

OutputDirDepth returns depth of output directory

func Runner

func Runner(config *Config, tasks ...Task) error

Types

type Config

type Config struct {
	DBConfig   *database.Config `json:"database" yaml:"database"`
	Migrations string

	//Models     *Options            `json:"models,omitempty" yaml:"models,omitempty"`
	//Repository *Options            `json:"repository,omitempty" yaml:"repository,omitempty"`
	Tasks map[string]*Options `json:"tasks" yaml:"tasks"`

	Debug bool `toml:"debug,omitempty" json:"debug,omitempty" yaml:"debug,omitempty"`

	NoEditDisclaimer []byte
	Verbose          bool   `json:"verbose" yaml:"verbose"`
	Version          string `toml:"-" json:"-" yaml:"-"`

	Schema StringList `yaml:"schema,omitempty"`
}

type DataField

type DataField struct {
	Name       string
	IsRequired bool
	IsRelation bool
	Type       string
}

type Field

type Field struct {
	IsRequired bool
	IsRelation bool

	SchemaField *DataField
	TableField  *DataField

	ToTableField  string
	ToObjectField string
}

Object will exist if a model has both a matching table and schema

type FieldList

type FieldList []Field

type Model

type Model struct {
	Name   string
	Table  database.Table
	Schema schema.Type
}

func (*Model) HasObject

func (m *Model) HasObject() bool

func (*Model) Object

func (m *Model) Object() Object

type Object

type Object struct {
	Name   string
	Fields FieldList
}

Object will exist if a model has both a matching table and schema

type Options

type Options struct {
	Name              string `json:"name" yaml:"name"`
	Debug             bool   `json:"debug,omitempty" yaml:"debug,omitempty"`
	OutFolder         string `json:"out_folder,omitempty" yaml:"output,omitempty"`
	PkgName           string `json:"pkgname,omitempty" yaml:"pkgname,omitempty"`
	PluralFileNames   bool   `json:"plural_file_names" yaml:"plural_file_names"`
	NoTests           bool   `json:"no_tests,omitempty" yaml:"no_tests,omitempty"`
	Wipe              bool   `json:"wipe,omitempty" yaml:"wipe,omitempty"`
	NoGeneratedHeader bool   `json:"no_generated_header,omitempty" yaml:"no_generated_header,omitempty"`

	Tags            []string `json:"tags,omitempty" yaml:"tags,omitempty"`
	TagIgnore       []string `json:"tag_ignore" yaml:"tag_ignore"`
	StructTagCasing string   `json:"struct_tag_casing" yaml:"struct_tag_casing"`

	TemplateDirs []string             `json:"template_dirs" yaml:"template_dirs"`
	Imports      importers.Collection `json:"imports" yaml:"imports"`
	Replacements []string             `json:"replacements,omitempty" yaml:"replacements,omitempty"`
}

func (*Options) ConfigureImports

func (o *Options) ConfigureImports(defaultImport func() importers.Collection) importers.Collection

func (*Options) Init

func (o *Options) Init(defaultOptions func() Options) error

type Simmer

type Simmer struct {
	Config *Config
	Data   *data.Data
	Schema *schema.Schema
	Model  *Model

	Options interface{}
	// contains filtered or unexported fields
}

Simmer holds the global data needed by most pieces to run

func New

func New(cfg *Config) (*Simmer, error)

New creates a new state based off of the config

func (*Simmer) Cleanup

func (s *Simmer) Cleanup() error

Cleanup closes any resources that must be closed

func (*Simmer) Models

func (s *Simmer) Models() []*Model

type StringList

type StringList []string

func (StringList) Has

func (a StringList) Has(file string) bool

func (*StringList) UnmarshalYAML

func (a *StringList) UnmarshalYAML(unmarshal func(interface{}) error) error

type Task

type Task interface {
	Name() string
	Run(schema *Simmer) error
}

type Tasks

type Tasks []Task

func (*Tasks) AddTask

func (tt *Tasks) AddTask(task Task, override bool) error

func (*Tasks) Append

func (tt *Tasks) Append(task Task)

Jump to

Keyboard shortcuts

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