compile

package
v0.0.0-...-e92a53e Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileToFile

func CompileToFile(fn string, c *cli.Context, com Compiler) (err error)

CompileToFile compiles to file according to given CLI flags output: output file name

func FormatFile

func FormatFile(fn string) error

FormatFile formats a generated file with go formatter

func SubfixFn

func SubfixFn(subfix string) func(string) string

SubfixFn return a normalizer which takes a string, subfix it and add .go to the end

Types

type Compiler

type Compiler interface {
	Compile(w io.Writer, c *cli.Context) error
}

Compiler takes a CLI context, decode it and compile to the io writer

func NewCompiler

func NewCompiler(dec DecoderFunc, enc EncoderFunc) Compiler

NewCompiler takes decoder and encoder and use them in file compilation

type Context

type Context map[string]interface{}

Context for template compilation

func (Context) GetStr

func (c Context) GetStr(key string) string

GetStr gets a value of string Type

func (Context) Set

func (c Context) Set(key string, v interface{})

Add stores a value to the key

type DecoderFunc

type DecoderFunc func(c *cli.Context) (ctx Context, err error)

DecoderFunc decode a given CLI context into a compile context

type EncoderFunc

type EncoderFunc func(w io.Writer, ctx Context) error

EncoderFunc compiles a given comiple context and output result to the io.Writer

type GourdError

type GourdError interface {
	Code() int
	Error() string
}

GourdError is interface

func Error

func Error(msg string, v ...interface{}) GourdError

Error returns a GourdError with "fail" return code

func Errorf

func Errorf(msg string, v ...interface{}) GourdError

Errorf is an alias of Error

func Exit

func Exit(msg string, v ...interface{}) GourdError

Exit returns a GourdError with "success" return code

Jump to

Keyboard shortcuts

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