build

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRepository is local repository root directory
	DefaultRepository = "~/.neon"
	// RegexpPlugin is regexp for a plugin name
	RegexpPlugin = `[\w-]+/[\w-]+`
)
View Source
const (
	// character that start expressions
	CharExpression = "="
	// expression curly brace
	CurlyExpression = "{"
	// tag name
	NeonTag = "neon"
	// tag separator
	TagSeparator = ","
	// field might not be provided
	FieldOptional = "optional"
	// field is a file name that is expanded for user home
	FieldFile = "file"
	// field is an expression
	FieldExpression = "expression"
	// field should be rapped in a slice of its type
	FieldWrap = "wrap"
	// field is a list of steps
	FieldSteps = "steps"
	// field has a different name
	FieldName = "name"
)

character for expressions

View Source
const (
	// PluginSite is default site for plugins
	PluginSite = "github.com"
)

Variables

View Source
var Attributes = map[string]color.Attribute{
	"Reset":        color.Reset,
	"Bold":         color.Bold,
	"Faint":        color.Faint,
	"Italic":       color.Italic,
	"Underline":    color.Underline,
	"BlinkSlow":    color.BlinkSlow,
	"BlinkRapid":   color.BlinkRapid,
	"ReverseVideo": color.ReverseVideo,
	"Concealed":    color.Concealed,
	"CrossedOut":   color.CrossedOut,
	"FgBlack":      color.FgBlack,
	"FgRed":        color.FgRed,
	"FgGreen":      color.FgGreen,
	"FgYellow":     color.FgYellow,
	"FgBlue":       color.FgBlue,
	"FgMagenta":    color.FgMagenta,
	"FgCyan":       color.FgCyan,
	"FgWhite":      color.FgWhite,
	"FgHiBlack":    color.FgHiBlack,
	"FgHiRed":      color.FgHiRed,
	"FgHiGreen":    color.FgHiGreen,
	"FgHiYellow":   color.FgHiYellow,
	"FgHiBlue":     color.FgHiBlue,
	"FgHiMagenta":  color.FgHiMagenta,
	"FgHiCyan":     color.FgHiCyan,
	"FgHiWhite":    color.FgHiWhite,
	"BgBlack":      color.BgBlack,
	"BgRed":        color.BgRed,
	"BgGreen":      color.BgGreen,
	"BgYellow":     color.BgYellow,
	"BgBlue":       color.BgBlue,
	"BgMagenta":    color.BgMagenta,
	"BgCyan":       color.BgCyan,
	"BgWhite":      color.BgWhite,
	"BgHiBlack":    color.BgHiBlack,
	"BgHiRed":      color.BgHiRed,
	"BgHiGreen":    color.BgHiGreen,
	"BgHiYellow":   color.BgHiYellow,
	"BgHiBlue":     color.BgHiBlue,
	"BgHiMagenta":  color.BgHiMagenta,
	"BgHiCyan":     color.BgHiCyan,
	"BgHiWhite":    color.BgHiWhite,
}

Attributes values by name

View Source
var BuiltinMap = make(map[string]BuiltinDesc)

BuiltinMap is a map of builtin descriptors by name

View Source
var Fields = []string{"doc", "default", "extends", "repository", "context", "singleton",
	"shell", "properties", "configuration", "expose", "environment", "targets", "version"}

Fields is the list of possible root fields for a build file

View Source
var Grey = false

Grey is a flag that tells if we print on console without color

View Source
var NeonVersion = "UNKNOWN"

NeonVersion is passed while compiling

View Source
var RegexSuffixes = `SNAPSHOT|ALPHA|BETA|RC|snapshot|alpha|beta|rc`

RegexSuffixes is a regexp for version suffixes

View Source
var RegexpLinkName = regexp.MustCompile(`[^/]+/[^/]+/[^/]+.yml`)

RegexpLinkName is regexp for parent name

View Source
var RegexpParentName = regexp.MustCompile(`[^/]+/[^/]+/[^/]+.yml`)

RegexpParentName is regexp for parent name

View Source
var RegexpScriptName = regexp.MustCompile(`[^/]+/[^/]+/[^/]+.ank`)

RegexpScriptName is regexp for script name

View Source
var RegexpTemplateName = regexp.MustCompile(`[^/]+/[^/]+/[^/]+.tpl`)

RegexpTemplateName is regexp for template name

View Source
var RegexpVersion = regexp.MustCompile(`^(\d+(\.\d+)*)(-(` + RegexSuffixes + `)(-\d+)?)?$`)

RegexpVersion is a regexp for version

View Source
var TaskMap = make(map[string]TaskDesc)

TaskMap is a map that gives constructor for given task name

View Source
var Themes = map[string]*Theme{
	"bee": {
		Title: []color.Attribute{color.FgYellow},
		Ok:    []color.Attribute{color.FgGreen, color.Bold},
		Error: []color.Attribute{color.FgRed, color.Bold},
	},
	"rgb": {
		Title: []color.Attribute{color.FgBlue},
		Ok:    []color.Attribute{color.FgGreen, color.Bold},
		Error: []color.Attribute{color.FgRed, color.Bold},
	},
	"red": {
		Title: []color.Attribute{color.FgRed},
		Ok:    []color.Attribute{color.FgRed, color.Bold},
		Error: []color.Attribute{color.FgRed, color.Bold, color.ReverseVideo},
	},
	"green": {
		Title: []color.Attribute{color.FgGreen},
		Ok:    []color.Attribute{color.FgGreen, color.Bold},
		Error: []color.Attribute{color.FgGreen, color.Bold, color.ReverseVideo},
	},
	"blue": {
		Title: []color.Attribute{color.FgBlue},
		Ok:    []color.Attribute{color.FgBlue, color.Bold},
		Error: []color.Attribute{color.FgBlue, color.Bold, color.ReverseVideo},
	},
	"yellow": {
		Title: []color.Attribute{color.FgYellow},
		Ok:    []color.Attribute{color.FgYellow, color.Bold},
		Error: []color.Attribute{color.FgYellow, color.Bold, color.ReverseVideo},
	},
	"magenta": {
		Title: []color.Attribute{color.FgMagenta},
		Ok:    []color.Attribute{color.FgMagenta, color.Bold},
		Error: []color.Attribute{color.FgMagenta, color.Bold, color.ReverseVideo},
	},
	"cyan": {
		Title: []color.Attribute{color.FgCyan},
		Ok:    []color.Attribute{color.FgCyan, color.Bold},
		Error: []color.Attribute{color.FgCyan, color.Bold, color.ReverseVideo},
	},
	"fire": {
		Title: []color.Attribute{color.FgRed},
		Ok:    []color.Attribute{color.FgGreen, color.Bold, color.Underline},
		Error: []color.Attribute{color.FgRed, color.Bold, color.Underline},
	},
	"marine": {
		Title: []color.Attribute{color.FgBlue},
		Ok:    []color.Attribute{color.FgGreen, color.Bold, color.Underline},
		Error: []color.Attribute{color.FgRed, color.Bold, color.Underline},
	},
	"nature": {
		Title: []color.Attribute{color.FgGreen},
		Ok:    []color.Attribute{color.FgGreen, color.Bold, color.Underline},
		Error: []color.Attribute{color.FgRed, color.Bold, color.Underline},
	},
	"bold": {
		Title: []color.Attribute{color.FgYellow, color.Bold},
		Ok:    []color.Attribute{color.FgGreen, color.Underline, color.Bold},
		Error: []color.Attribute{color.FgRed, color.Underline, color.Bold},
	},
	"reverse": {
		Title: []color.Attribute{color.ReverseVideo},
		Ok:    []color.Attribute{color.ReverseVideo, color.Bold},
		Error: []color.Attribute{color.ReverseVideo, color.Bold},
	},
}

Themes is a map of themes by name

Functions

func AddBuiltin

func AddBuiltin(desc BuiltinDesc)

AddBuiltin adds given builtin to the map - desc: builtin description

func AddTask

func AddTask(task TaskDesc)

AddTask adds a task in the map: - task: description of the task

func ApplyTheme

func ApplyTheme(theme *Theme)

ApplyTheme applies given theme

func ApplyThemeByName

func ApplyThemeByName(name string) error

ApplyThemeByName applies named theme

func CheckTaskArgs

func CheckTaskArgs(m map[string]TaskDesc, t TaskDesc) error

CheckTaskArgs checks that task argument names don't collide with with the name of an existing task. For instance, a task can't have an argument named copy as a task named copy already exists. - map: the tasks map. - task: the task description. Return: an error if argument collides.

func CheckType

func CheckType(field reflect.StructField, value interface{}) bool

CheckType checks that given value is compatible with field type - field: the field of the parameters as reflect.StructField - value: the value of the argument Return: a bool that tells if type is OK

func CopyValue

func CopyValue(orig, dest reflect.Value)

CopyValue copy given value in another - orig: origin value - dest: destination value

func EvaluateTaskArgs

func EvaluateTaskArgs(args TaskArgs, typ reflect.Type, context *Context) (result interface{}, err error)

EvaluateTaskArgs builds task arguments from task params and return it - args: task arguments parsed in build file - typ: the type of the arguments - context: the build context to evaluate arguments into Return: - result: as an interface{} - error: if something went wrong

func FieldIs

func FieldIs(field reflect.StructField, quality string) bool

FieldIs tells if given field tag contains quality - field: the struct field - quality: the tested quality (such as "optional")

func FindParent

func FindParent(parent, repository string) ([]string, error)

FindParent finds a parent in given repository. - parent: the parent to find (such as "golang"). - repository: the NeON repository (defaults to '~/.neon') Return: - parent path relative to repository (such as "c4s4/build/golang.tpl"). - error if something went wrong.

func FindParents

func FindParents(repository string) ([]string, error)

FindParents finds parent build files in given repository. - repository: the NeON repository (defaults to '~/.neon') Return: - list of parent build files relative to repo. - error if something went wrong.

func FindTemplate

func FindTemplate(template, repository string) ([]string, error)

FindTemplate finds a template in given repository. - template: the template to find (such as "golang"). - repository: the NeON repository (defaults to '~/.neon') Return: - templates path relative to repo (such as "c4s4/build/golang.tpl"). - error if something went wrong.

func FindTemplates

func FindTemplates(repository string) ([]string, error)

FindTemplates finds templates in given repository. - repository: the NeON repository (defaults to '~/.neon') Return: - list of template files relative to repo. - error if something went wrong.

func FormatScriptError

func FormatScriptError(err error) error

FormatScriptError adds line and column numbers on parser or vm errors. - err: the error to process Return: the processed error

func FormatTarget

func FormatTarget(name, doc string, depends []string, length int) string

FormatTarget generates target documentation on console - name: the name of the target - doc: the target documentation - depends: targets on which this one depends - length: title length to align help on targets Return: target as a string

func GetQuality

func GetQuality(field reflect.StructField, quality string) string

GetQuality returns value of given quality - field: the field to examine - quality: quality to get

func HasField

func HasField(t reflect.Type, n string) bool

HasField tells if given structure has named field. - t: the type to check (must be a struct). - n: the name of the field to check as a string. Return: a boolean that tells if field exists.

func Info

func Info(text string, args ...interface{})

Info prints an information message on console: - text: text to print (that might embed fields to print, such as "%s") - args: arguments for the text to print

func InfoBuiltin

func InfoBuiltin(builtin string) string

InfoBuiltin generates help on given builtin: - builtin: the name of the builtin to document. Return: builtin info as a string

func InfoBuiltins

func InfoBuiltins() string

InfoBuiltins generates the list of all builtins on console Return: builtins list as a string

func InfoBuiltinsReference

func InfoBuiltinsReference() string

InfoBuiltinsReference generates markdown reference for builtins on console. Return: reference as a string

func InfoParents

func InfoParents(repository string) string

InfoParents generates list of parent build files in repository: - repository: the NeON repository (defaults to '~/.neon') Return: parents info as a string

func InfoTask

func InfoTask(task string) string

InfoTask generates help on given task. - task: name of the task to document. Return: task info as a string

func InfoTasks

func InfoTasks() string

InfoTasks generates the list of tasks on the console. Return: list of tasks as a string

func InfoTasksReference

func InfoTasksReference() string

InfoTasksReference generates markdown reference for tasks on console. Return: reference as a string

func InfoTemplates

func InfoTemplates(repository string) string

InfoTemplates generates list of templates in repository: - repository: the NeON repository (defaults to '~/.neon') Return: template info as a string

func InfoThemes

func InfoThemes() string

InfoThemes generates the list of all available themes. Return: info about themes as a string

func InstallPlugin

func InstallPlugin(plugin, repository string) error

InstallPlugin installs given plugin in repository:

  • plugin: the plugin name such as c4s4/build. First part us Github user name and second is repository name for the plugin.
  • repository: plugin repository, defaults to ~/.neon.

Return: an error if something went wrong downloading plugin.

func IsExpression

func IsExpression(s string) bool

IsExpression tells if given string is an expression - s: the string to test Return: a bool that tells if the string is an expression

func IsValueOfType

func IsValueOfType(value interface{}, typ reflect.Type) bool

IsValueOfType tells if a value is of given type - value: the value to test as an interface{} - type: the type to check as a reflect.Type Return: a bool telling if value is of given type

func LinkPath

func LinkPath(name, repository string) string

LinkPath return the link path: - name: the name of the build file (such as 'c4s4/build/build.yml') - repository: the repository for plugins (defaults to '~/.neon') Return: link path (as '~/.neon/c4s4/build/build.yml')

func ListenPort

func ListenPort(port int) (net.Listener, error)

ListenPort listens given port: - port: port to listen. Return: listener and error if any

func LoadBuiltins

func LoadBuiltins(vm *vm.Env)

LoadBuiltins loads defined builtins in the VM - vm: the VM to load builtins into

func Message

func Message(text string, args ...interface{})

Message prints a message on console: - text: text to print (that might embed fields to print, such as "%s") - args: arguments for the text to print

func ParseAttributes

func ParseAttributes(colors []string) ([]color.Attribute, error)

ParseAttributes parse attributes

func ParseConfiguration

func ParseConfiguration(object util.Object, build *Build) error

ParseConfiguration parses configuration field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseContext

func ParseContext(object util.Object, build *Build) error

ParseContext parses context field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseDefault

func ParseDefault(object util.Object, build *Build) error

ParseDefault parses default field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseDoc

func ParseDoc(object util.Object, build *Build) error

ParseDoc parses doc field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseEnvironment

func ParseEnvironment(object util.Object, build *Build) error

ParseEnvironment parses environment field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseExpose

func ParseExpose(object util.Object, build *Build) error

ParseExpose parses list of targets to expose on the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseExtends

func ParseExtends(object util.Object, build *Build) error

ParseExtends parses extends field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseFields

func ParseFields(object util.Object, build *Build, repo string) error

ParseFields parses build file fields: - object: the build as an object. - build: the build object. - repo: the repository. Return: an error if something went wrong.

func ParseProperties

func ParseProperties(object util.Object, build *Build) error

ParseProperties parses properties field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseRepository

func ParseRepository(object util.Object, build *Build, repository string) error

ParseRepository parses repository field of the build: - object: the object to parse - build: build that is being constructed - repo: repository location passed on command line Return: an error if something went wrong

func ParseShell

func ParseShell(object util.Object, build *Build) error

ParseShell parses shell field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseSingleton

func ParseSingleton(object util.Object, build *Build) error

ParseSingleton parses singleton field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseTargetDepends

func ParseTargetDepends(object util.Object, target *Target) error

ParseTargetDepends parses target dependencies: - object: the target body as an interface - target: the target being parsed Return: an error if something went wrong

func ParseTargetDoc

func ParseTargetDoc(object util.Object, target *Target) error

ParseTargetDoc parses documentation of the target: - object: body of the target as an interface - target: the target to document Return: an error if something went wrong

func ParseTargetSteps

func ParseTargetSteps(object util.Object, target *Target) error

ParseTargetSteps parses steps of a target: - object: the target body as an interface - target: the target being parsed Return: an error if something went wrong

func ParseTargetUnless

func ParseTargetUnless(object util.Object, target *Target) error

ParseTargetUnless parses unless clause of the target: - object: body of the target as an interface - target: the target to document Return: an error if something went wrong

func ParseTargets

func ParseTargets(object util.Object, build *Build) error

ParseTargets parses targets field of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func ParseVersion

func ParseVersion(object util.Object, build *Build) error

ParseVersion parses NeON version requirement of the build: - object: the object to parse - build: build that is being constructed Return: an error if something went wrong

func PrintError

func PrintError(text string)

PrintError prints a red ERROR on the console followed with an explanatory text - text: the explanatory text to print

func PrintOk

func PrintOk()

PrintOk prints a green OK on the console

func PropertyToString

func PropertyToString(object interface{}, quotes bool) (string, error)

PropertyToString returns a string representation of given property: - object: the body of the property as an interface - quotes: tells if we want quotes around strings Return: - string representation of the property - an error if something went wrong

func SetDirectories

func SetDirectories(build *Build, base string) error

SetDirectories sets build and base directories: - build: the build directory. - base: the base directory. Return: an error if something went wrong.

func TemplatePath

func TemplatePath(name, repository string) (string, error)

TemplatePath return the template path: - name: the name of the template (such as 'c4s4/build/golang.tpl') - repository: the repository for plugins (defaults to '~/.neon') Return: template path (as '~/.neon/c4s4/build/golang.tpl')

func Title

func Title(text string)

Title prints a title on the console - text: text of the title to print

func Update

func Update(repository string) error

Update updates Neon and repository: - repository: the repository path. Return: error if something went wrong

func ValidateTaskArgs

func ValidateTaskArgs(args TaskArgs, typ reflect.Type) error

ValidateTaskArgs validates arguments against task arguments definition - args: task arguments parsed in build file - typ: type of the arguments Return: an error (detailing the fault) if arguments are illegal

Types

type Build

type Build struct {
	File        string
	Dir         string
	Here        string
	Default     []string
	Doc         string
	Repository  string
	Singleton   string
	Shell       map[string][]string
	Scripts     []string
	Extends     []string
	Config      []string
	Expose      []string
	Properties  util.Object
	Environment map[string]string
	Targets     map[string]*Target
	Parents     []*Build
	Root        *Build
	Version     string
	Template    bool
}

Build structure

func NewBuild

func NewBuild(file, base, repo string, template bool) (*Build, error)

NewBuild makes a build from a build file - file: path of the build file - base: base of the build - repo: repository location Return: - Pointer to the build - error if something went wrong

func (*Build) CheckVersion

func (build *Build) CheckVersion(context *Context) error

CheckVersion checks evaluates version expression to check that NeON version is OK

func (*Build) EnsureSingle

func (build *Build) EnsureSingle(context *Context) (net.Listener, error)

EnsureSingle runs a TCP server on given port to ensure that a single instance is running on a machine. Fails if another instance is already running on same port. - context: build context Return: a listener and an error if another instance is running on same port

func (*Build) FormatTargets

func (build *Build) FormatTargets() string

FormatTargets generates help on targets Return: targets as a string

func (*Build) GetDefault

func (build *Build) GetDefault() []string

GetDefault returns default targets. If none is defined in build, return those from parent build files. Return: default targets a slice of strings

func (*Build) GetEnvironment

func (build *Build) GetEnvironment() map[string]string

GetEnvironment returns the build environment, including the environment inherited from parents Return: environment as a map with string keys and values

func (*Build) GetParentTarget

func (build *Build) GetParentTarget(name string) (*Target, error)

GetParentTarget return parent target with given name. - name: the name of the target to run Return: - target: found parent target, nil if none was found - error: if something went wrong

func (*Build) GetParents

func (build *Build) GetParents() ([]*Build, error)

GetParents returns parent build objects. Return list of build objects and an error if any.

func (*Build) GetProperties

func (build *Build) GetProperties() util.Object

GetProperties returns build properties, including those inherited from parents Return: build properties as an Object

func (*Build) GetScripts

func (build *Build) GetScripts() []string

GetScripts return a list of context scripts to run. Return: the list of context scripts

func (*Build) GetShell

func (build *Build) GetShell() ([]string, error)

GetShell return shell for current os. Return: - shell as a slice of strings (such as ["sh", "-c"]) - error if something went wrong

func (*Build) GetTarget

func (build *Build) GetTarget(name string) *Target

GetTarget return target with given name. If not defined in build, return target inherited from parent - name: the target name as a string Return: found target

func (*Build) GetTargets

func (build *Build) GetTargets() map[string]*Target

GetTargets returns build targets, including those inherited from parents Return: targets as a map of targets with their name as keys

func (*Build) Info

func (build *Build) Info(context *Context) (string, error)

Info generates information about build on console. - context: context of the build Return: build info as a string and an error if something went wrong

func (*Build) ParentPath

func (build *Build) ParentPath(name string) (string, error)

ParentPath returns file path for plugin with given name. - name: the name of the plugin (as "c4s4/build/foo.yml" or "foo") Return: - the plugin path as a string (as /home/casa/.neon/c4s4/build/foo.yml) - error if something went wrong

func (*Build) Run

func (build *Build) Run(context *Context, targets []string) error

Run runs given targets in a build context. If no target is given, runs default one. - context: the context to run into - targets: targets to run as a slice of strings Return: error if something went wrong

func (*Build) RunParentTarget

func (build *Build) RunParentTarget(context *Context, name string) error

RunParentTarget runs parent target with given name in a build context. - context: build context - name: the name of the target to run Return: - boolean: that tells if parent target was found - error: if something went wrong

func (*Build) RunTarget

func (build *Build) RunTarget(context *Context, name string) error

RunTarget runs given target in a build context. - context: build context - name: name of the target to run as a string Return: an error if something went wrong

func (*Build) ScriptPath

func (build *Build) ScriptPath(name string) (string, error)

ScriptPath returns file path for script with given name. - name: the name of the script (as "c4s4/build/foo.ank") Return: - the script path as a string (as /home/casa/.neon/c4s4/build/foo.ank) - error if something went wrong

func (*Build) SetCommandLineProperties

func (build *Build) SetCommandLineProperties(props string) error

SetCommandLineProperties defines properties passed on command line in the context. These properties overwrite those define in the build file. - props: properties as a YAML map Return: error if something went wrong

func (*Build) SetDir

func (build *Build) SetDir(dir string)

SetDir sets the build directory, propagating to parents - dir: build directory as a string

func (*Build) SetRoot

func (build *Build) SetRoot(root *Build)

SetRoot sets the root build, propagating to parents - build: root build

func (*Build) SubTree

func (build *Build) SubTree(margin string, next bool)

SubTree prints the inheritance SubTree for given build

func (*Build) Tree

func (build *Build) Tree()

Tree prints the inheritance tree for given build

type BuiltinDesc

type BuiltinDesc struct {
	Name string
	Func interface{}
	Help string
}

BuiltinDesc is a descriptor for a builtin function

type Colors

type Colors struct {
	Title []string
	Ok    []string
	Error []string
}

Colors define a theme

type Context

type Context struct {
	VM    *vm.Env
	Build *Build
	Stack *Stack
}

Context is the context of the build - VM: Anko VM that holds build properties - Build: the current build - Index: tracks steps index while running build - Stack: tracks targets calls

func NewContext

func NewContext(build *Build) *Context

NewContext make a new build context Return: a pointer to the context

func (*Context) Copy

func (context *Context) Copy() *Context

Copy performs a deep copy of the Context Return: a pointer to the context copy

func (*Context) DelProperty

func (context *Context) DelProperty(name string) error

DelProperty deletes given property - name: the name of the property Return: - an error if something went wrong

func (*Context) EvaluateEnvironment

func (context *Context) EvaluateEnvironment() ([]string, error)

EvaluateEnvironment evaluates environment variables in the context Return: - evaluated environment as a slice of strings - an error if something went wrong

func (*Context) EvaluateExpression

func (context *Context) EvaluateExpression(expression string) (interface{}, error)

EvaluateExpression evaluate given expression in the context - expression: the expression to evaluate Return: - the return value of the expression - an error if something went wrong

func (*Context) EvaluateObject

func (context *Context) EvaluateObject(object interface{}) (interface{}, error)

EvaluateObject recursively evaluates strings in a structure - object: the object to evaluate Return: - evaluated copy of object - an error if something went wrong

func (*Context) EvaluateString

func (context *Context) EvaluateString(text string) (string, error)

EvaluateString replaces '#{expression}' with the value of the expression - text: the string to evaluate Return: - evaluated string - an error if something went wrong

func (*Context) GetProperty

func (context *Context) GetProperty(name string) (interface{}, error)

GetProperty returns value of given property - name: the name of the property Return: - the value of the property - an error if something went wrong

func (*Context) Init

func (context *Context) Init() error

Init initializes context with build Return: an error if something went wrong

func (*Context) InitProperties

func (context *Context) InitProperties() error

InitProperties sets build properties Return: an error if something went wrong

func (*Context) InitScripts

func (context *Context) InitScripts() error

InitScripts loads build scripts in context Return: an error if something went wrong

func (*Context) Message

func (context *Context) Message(text string, args ...interface{})

Message print a message on the console - text: the text to print on console - args: a slice of string arguments (as for fmt.Printf())

func (*Context) SetProperty

func (context *Context) SetProperty(name string, value interface{})

SetProperty sets given property in context - name: the name of the property - value: the value of the property

type ScriptStep

type ScriptStep struct {
	Script string
}

ScriptStep is made of a string

func (ScriptStep) Run

func (step ScriptStep) Run(context *Context) error

Run a script step using Anko VM. - context: the build context to run tha script Return: an error if something went wrong

type Stack

type Stack struct {
	Targets []*Target
}

Stack is structure for a stack. A stack lists all targets that run during a build.

func NewStack

func NewStack() *Stack

NewStack makes a new stack Returns: a pointer to the stack

func (*Stack) Contains

func (stack *Stack) Contains(name string) bool

Contains tells if the stack contains given target - target: target to test Returns: a boolean telling if target is in the stack

func (*Stack) Copy

func (stack *Stack) Copy() *Stack

Copy returns a copy of the stack Return: pointer to a copy of the stack

func (*Stack) Last

func (stack *Stack) Last() *Target

Last gets the last target on stack Return: last target on stack

func (*Stack) Pop

func (stack *Stack) Pop() error

Pop target on the stack Return: error if something went wrong

func (*Stack) Push

func (stack *Stack) Push(target *Target) error

Push a target on the stack - target: target to push on the stack Return: an error if we are in an infinite loop

func (*Stack) String

func (stack *Stack) String() string

ToString returns string representation of the stack, such as: "foo -> bar -> spam" Return: the stack as a string

type Step

type Step interface {
	Run(context *Context) error
}

Step has a Run() method

func NewScriptStep

func NewScriptStep(script string) (Step, error)

NewScriptStep makes a new script step - script: the script as a string - built step - error if something went wrong

func NewStep

func NewStep(step interface{}) (Step, error)

NewStep makes a new step - step: body of the step as an interface Return: - built step - error if something went wrong

func NewTaskStep

func NewTaskStep(args TaskArgs) (Step, error)

NewTaskStep makes a task step - args: task args Return: - built step - error if something went wrong

type Steps

type Steps []Step

Steps is a list of steps

func NewSteps

func NewSteps(object interface{}) (Steps, error)

NewSteps makes a new steps - object: body of the steps as an interface Return: - steps - an error if something went wrong

func (Steps) Run

func (steps Steps) Run(context *Context) error

Run steps in context - context: the context for running Return: an error if something went wrong

type Target

type Target struct {
	Build   *Build
	Name    string
	Doc     string
	Depends []string
	Unless  string
	Steps   Steps
}

Target is a structure for a target

func NewTarget

func NewTarget(build *Build, name string, object util.Object) (*Target, error)

NewTarget makes a new target: - build: the build of the target - name: the name of the target - object: the body of the target as an interface Returns: - a pointer to the built target - an error if something went wrong

func (*Target) Run

func (target *Target) Run(context *Context) error

Run target in given context: - context: the context of the build Return: an error if something went wrong

type TaskArgs

type TaskArgs map[interface{}]interface{}

TaskArgs is a type for task arguments as parsed in build file

type TaskDesc

type TaskDesc struct {
	Name string
	Args reflect.Type
	Func TaskFunc
	Help string
}

TaskDesc is a task descriptor is made of a task constructor and an help string

type TaskFunc

type TaskFunc func(ctx *Context, args interface{}) error

TaskFunc is a type for task function called to run task

type TaskStep

type TaskStep struct {
	Desc TaskDesc
	Args TaskArgs
}

TaskStep for a task step

func (TaskStep) Run

func (step TaskStep) Run(context *Context) error

Run a task step, calling the function for the step - context: build context Return: an error if something went wrong

type Theme

type Theme struct {
	Title []color.Attribute
	Ok    []color.Attribute
	Error []color.Attribute
}

Theme defined by colors

func ParseTheme

func ParseTheme(colors *Colors) (*Theme, error)

ParseTheme parses colors and returns a Theme

type Version

type Version struct {
	String string
	Fields []int
}

Version encapsulates a software version such as x.y.z

func NewVersion

func NewVersion(version string) (*Version, error)

NewVersion builds a Version from its string representation

func (*Version) Compare

func (v *Version) Compare(o *Version) int

Compare compares two versions. Returns: - <0 if version is lower than other - >0 if version is greater than other - =0 if versions are equal

func (*Version) Len

func (v *Version) Len() int

Len returns the length of the versions, that is the number of parts

Jump to

Keyboard shortcuts

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