marid

package module
v0.0.0-...-935a529 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: MIT Imports: 12 Imported by: 0

README

MaridBuild Status GoDoc Coverage Status license

A go code generator genie.

Install:

go get -u github.com/thrisp/marid.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyTemplateError = Mrror("empty template named %s").Out
	NoTemplateError    = Mrror("no template named %s").Out
	PathError          = Mrror("path: %s returned error").Out
	NoLoadMethod       = Mrror("load method not implemented")
	RenderError        = Mrror("render error: %s").Out
	InvalidGoCodeError = Mrror("error formatting go code: invalid Go generated: %s\ncompile the package to analyze the error").Out
	NoBlockError       = Mrror("no block named %s available").Out
)

Functions

func Mrror

func Mrror(err string) *maridError

Types

type BaseLoader

type BaseLoader struct {
	Errors         []error
	FileExtensions []string
}

func (*BaseLoader) ListTemplates

func (b *BaseLoader) ListTemplates() []string

func (*BaseLoader) Load

func (b *BaseLoader) Load(name string) (string, error)

func (*BaseLoader) ValidExtension

func (b *BaseLoader) ValidExtension(ext string) bool

type Block

type Block interface {
	Tag() string
	Flags() *flag.FlagSet
	Loaders() []Loader
	Funcs() map[string]interface{}
	Templates() []string
	Directory() string
	Package() string
}

func BasicBlock

func BasicBlock(t string, f *flag.FlagSet, l Loader, tm []string) Block

func NewBlock

func NewBlock(t string,
	f *flag.FlagSet,
	lr Loader,
	fn map[string]interface{},
	tm []string,
	d string,
	p string) Block

type BlockSet

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

func NewBlockSet

func NewBlockSet() *BlockSet

func (*BlockSet) AddBlocks

func (b *BlockSet) AddBlocks(bs ...Block)

func (*BlockSet) GetBlock

func (b *BlockSet) GetBlock(tag string) (Block, error)

func (*BlockSet) GetBlocks

func (b *BlockSet) GetBlocks() map[string]Block

type Config

type Config interface {
	Order() int
	Configure(*manager) error
}

func Blocks

func Blocks(b ...Block) Config

func DefaultConfig

func DefaultConfig(fn ConfigFn) Config

func Loaders

func Loaders(l ...Loader) Config

func NewConfig

func NewConfig(order int, fn ConfigFn) Config

func Verbose

func Verbose(is bool) Config

type ConfigFn

type ConfigFn func(*manager) error

type Configuration

type Configuration interface {
	Add(...Config)
	AddFn(...ConfigFn)
	Configure() error
	Configured() bool
}

type Doer

type Doer interface {
	Do(string, []string) error
}

type FuncSet

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

func NewFuncSet

func NewFuncSet() *FuncSet

func (*FuncSet) AddFuncs

func (f *FuncSet) AddFuncs(fns map[string]interface{})

func (*FuncSet) GetFuncs

func (f *FuncSet) GetFuncs() map[string]interface{}

type Loader

type Loader interface {
	Load(string) (string, error)
	ListTemplates() []string
}

func DirLoader

func DirLoader(paths ...string) Loader

func MapLoader

func MapLoader(tm ...map[string]string) Loader

type LoaderSet

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

func NewLoaderSet

func NewLoaderSet() *LoaderSet

func (*LoaderSet) AddLoaders

func (l *LoaderSet) AddLoaders(ls ...Loader)

func (*LoaderSet) GetLoaders

func (l *LoaderSet) GetLoaders(ls ...Loader) []Loader

type Logr

type Logr interface {
	Fatalf(string, ...interface{})
	Panicf(string, ...interface{})
	Printf(string, ...interface{})
	PrintIf(string, ...interface{})
}
var DefaultLogr Logr

type Marid

type Marid interface {
	Configuration
	Logr
	Doer
	Templater
}

func New

func New(cnf ...Config) Marid

type Node

type Node struct {
	Name string
	Src  string
}

type TemplateData

type TemplateData struct {
	Data map[string]interface{}
}

func NewTemplateData

func NewTemplateData(b Block, fs *flag.FlagSet) *TemplateData

type Templater

type Templater interface {
	Render(string, string, interface{}) error
	Fetch(string) (*template.Template, error)
}

Directories

Path Synopsis
blocks

Jump to

Keyboard shortcuts

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