makr

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Helpers = map[string]interface{}{
	"js_escape":   template.JSEscapeString,
	"html_escape": template.HTMLEscapeString,
	"json":        toJSON,
	"upcase":      strings.ToUpper,
	"downcase":    strings.ToLower,
}

Helpers that are automatically injected into templates.

Functions

func GoFmt

func GoFmt(files ...string) *exec.Cmd

GoFmt is command that will use `goimports` if available, or fail back to `gofmt` otherwise.

func GoGet

func GoGet(pkg string, opts ...string) *exec.Cmd

GoGet downloads and installs packages and dependencies

func GoInstall

func GoInstall(pkg string, opts ...string) *exec.Cmd

GoInstall compiles and installs packages and dependencies

Types

type Command

type Command struct {
	Should  ShouldFunc
	Command *exec.Cmd
}

Command wraps an exec.Cmd to be run

func NewCommand

func NewCommand(cmd *exec.Cmd) Command

NewCommand ready to run

func (Command) Run

func (c Command) Run(rootPath string, data Data) error

Run the generator

type Data

type Data map[string]interface{}

Data to be passed into generators

type File

type File struct {
	Path          string
	Template      string
	TemplateFuncs template.FuncMap
	Permission    os.FileMode
	Should        ShouldFunc
}

File to generate

func NewFile

func NewFile(path string, t string) File

NewFile set up with sensible defaults

func (File) Run

func (f File) Run(rootPath string, data Data) error

Run the generator

type Func

type Func struct {
	Should ShouldFunc
	Runner RunFn
}

Func to be run as a generator

func (Func) Run

func (f Func) Run(rootPath string, data Data) error

Run the generator

type Generator

type Generator struct {
	Runners []Runnable
	Should  ShouldFunc
	Data    Data
}

Generator is the top level construct that holds all of the Runnables

func New

func New() *Generator

New Generator

func (*Generator) Add

func (g *Generator) Add(r Runnable)

Add a Runnable generator to the list

func (*Generator) Run

func (g *Generator) Run(rootPath string, data Data) error

Run all of the generators

type RemoteFile

type RemoteFile struct {
	RemotePath string
	File
}

RemoteFile represents a remote file (URL) that you want to pull down and write into the project

func (RemoteFile) Run

func (f RemoteFile) Run(rootPath string, data Data) error

Run the generator

type RunFn

type RunFn func(string, Data) error

RunFn interface for a function that can be used as a runner

type Runnable

type Runnable interface {
	Run(string, Data) error
}

Runnable interface must be implemented to be considered a runnable generator

type ShouldFunc

type ShouldFunc func(Data) bool

ShouldFunc decides whether a generator should be run or not

Jump to

Keyboard shortcuts

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