internal

package
v0.0.0-...-cd3f7e3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgType

type ArgType struct {
	// DSN is the database string (ie, pgsql://user@blah:localhost:5432/dbname?args=)
	DSN string `arg:"positional,required,help:data source name"`

	// Out is the output path.
	Out string `arg:"-o,help:output path"`

	// TemplatePath is the path to use the user supplied templates instead of
	// the built in versions.
	TemplatePath string `arg:"--template-path,help:user supplied template path"`

	// BlackList is ignore table names
	BlackList []string `arg:"--black-list,help:ignore table names"`

	// Path is output path
	Path string `arg:"-"`

	// Package is output package name
	Package string `arg:"-"`

	// XoPath is generated path by xo
	XoPath string `arg:"-"`

	// XoPackage is generated package by xo
	XoPackage string `arg:"-"`

	// Loader is the load model.
	Loader *Loader `arg:"-"`

	// Generated is the generated templates after a run.
	Generated []TBuf `arg:"-"`
	// contains filtered or unexported fields
}

ArgType is the type that specifies the command line arguments.

func NewDefaultArgs

func NewDefaultArgs() *ArgType

NewDefaultArgs returns the default arguments.

func (*ArgType) ExecuteTemplate

func (a *ArgType) ExecuteTemplate(tt TemplateType, et EditableType, name string, obj interface{}) error

ExecuteTemplate loads and parses the supplied template with name and executes it with obj as the context.

func (*ArgType) NewTemplateFuncs

func (a *ArgType) NewTemplateFuncs() template.FuncMap

NewTemplateFuncs returns a set of template funcs bound to the supplied args.

func (*ArgType) TemplateLoader

func (a *ArgType) TemplateLoader(name string) ([]byte, error)

TemplateLoader loads templates from the specified name.

func (*ArgType) TemplateSet

func (a *ArgType) TemplateSet() *TemplateSet

TemplateSet retrieves the created template set.

type EditableType

type EditableType bool

Editable

const (
	FileEditableType    EditableType = true
	FileNotEditableType EditableType = false
)

func (EditableType) FileSuffix

func (e EditableType) FileSuffix() string

Suffix ...

func (EditableType) HeaderTemplate

func (e EditableType) HeaderTemplate() string

Package ...

type Field

type Field struct {
	Name    string
	Type    string
	NilType string
	IsArray bool
	IsPtr   bool
}

Field contains field information.

type Func

type Func struct {
	Package string
	Name    string
	Params  []*Field
	Return  *Field
}

Func ...

type Loader

type Loader struct {
	StructList func(*ast.File) []*Struct
	FuncList   func(*ast.File) []*Func
}

Loader ...

func NewLoader

func NewLoader() *Loader

NewLoader

func (Loader) LoadCodes

func (l Loader) LoadCodes(args *ArgType) error

LoadFile ...

type Struct

type Struct struct {
	Package string
	Name    string
	Fields  []*Field
}

Struct ...

type TBuf

type TBuf struct {
	TemplateType TemplateType
	EditableType EditableType
	Name         string
	Subname      string
	Buf          *bytes.Buffer
}

TBuf is to hold the executed templates.

type TBufSlice

type TBufSlice []TBuf

TBufSlice is a slice of TBuf compatible with sort.Interface.

func (TBufSlice) Len

func (t TBufSlice) Len() int

func (TBufSlice) Less

func (t TBufSlice) Less(i, j int) bool

func (TBufSlice) Swap

func (t TBufSlice) Swap(i, j int)

type TemplateSet

type TemplateSet struct {
	// contains filtered or unexported fields
}

TemplateSet is a set of templates.

func (*TemplateSet) Execute

func (ts *TemplateSet) Execute(w io.Writer, name string, obj interface{}) error

Execute executes a specified template in the template set using the supplied obj as its parameters and writing the output to w.

type TemplateType

type TemplateType uint

TemplateType represents a template type.

const (
	StructTemplate TemplateType = iota
	FuncTemplate
)

the order here will be the alter the output order per file.

func (TemplateType) String

func (tt TemplateType) String() string

String returns the name for the associated template type.

Jump to

Keyboard shortcuts

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