core

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EV_GLUE_PLAN_START = "glue:plan_start"
	EV_GLUE_PLAN_END   = "glue:plan_end"
	EV_GROUP_START     = "group:start"
	EV_GROUP_END       = "group:end"
	EV_NEW_TRACE       = "trace:new"
)
View Source
const GroupSeparator = "."
View Source
const NegationRune = '~'
View Source
const RootLevel = "root"
View Source
const SelectorFilterSeparator = ","
View Source
const Wildcard = "*"

Variables

This section is empty.

Functions

func AutoDetectScriptFile

func AutoDetectScriptFile() (string, error)

func GlueHome

func GlueHome() (string, error)

@auteur("Configuration")

XDG_CONFIG_HOME

Glue respects the `XDG_CONFIG_HOME` environment variable. If it is set, Glue will look for the configuration file in the directory specified by `XDG_CONFIG_HOME`. If the variable is not set, Glue will look for the configuration file in the default directory (`~/.config/glue`)

``` ~/.config/glue/glue.lua ```

func InstallNativeGlueModules

func InstallNativeGlueModules(glue *Glue)

func TryFindFile

func TryFindFile(directory string, filename string) (string, error)

func TryFindGlueFile

func TryFindGlueFile(path string) (string, error)

func ValidSelectorString

func ValidSelectorString(selector string) bool

Types

type Glue

type Glue struct {
	q.Eventful
	Testable

	Stack        GlueStack
	BluePrint    Blueprint
	Verbose      bool
	Done         bool
	Unsafe       bool
	FailFast     bool
	Log          *GlueLogger
	Modules      []*GluePlugin
	UserSelector Selector
	Cache        q.Cache[string]
	Context      context.Context
	Runtime      runtime.Runtime
	Machine      machine.Machine
}

func NewGlue

func NewGlue() *Glue

func NewGlueWithOptions

func NewGlueWithOptions(options GlueOptions) *Glue

func (*Glue) Close

func (glue *Glue) Close()

func (*Glue) CompilePlan

func (glue *Glue) CompilePlan(file string) (Blueprint, error)

Main entry point for glue Given a script file, it compiles it into an executable plan

func (*Glue) Getwd

func (glue *Glue) Getwd() (string, error)

Getwd returns the working directory of the active script or the current working directory

func (*Glue) Plug

func (glue *Glue) Plug(name string, kind PluginKind) *plugin

Entry point for creating a new module

Example:

glue.Plug().
   Name("myModule").
   Short("description").
   Do(...)

func (*Glue) SmartPath

func (glue *Glue) SmartPath(path string) (string, error)

SmartPath resolves a path to an absolute path If called from within a script, it resolves the path relative to the script's directory

type GlueCodeGroup

type GlueCodeGroup struct {
	Name        string
	Annotations map[string]string
}

func (*GlueCodeGroup) Get

func (grp *GlueCodeGroup) Get(key string) (string, bool)

func (*GlueCodeGroup) Set

func (grp *GlueCodeGroup) Set(key string, value string)

type GlueLogger

type GlueLogger struct {
	Stdout GlueWriter
	Stderr GlueWriter
	// contains filtered or unexported fields
}

func CreateLogger

func CreateLogger() *GlueLogger

func (*GlueLogger) Debug

func (gl *GlueLogger) Debug(msg interface{}, keyvals ...interface{})

func (*GlueLogger) Debugf

func (gl *GlueLogger) Debugf(format string, args ...interface{})

func (*GlueLogger) Error

func (gl *GlueLogger) Error(msg interface{}, keyvals ...interface{})

func (*GlueLogger) Errorf

func (gl *GlueLogger) Errorf(format string, args ...interface{})

func (*GlueLogger) Info

func (gl *GlueLogger) Info(msg interface{}, keyvals ...interface{})

func (*GlueLogger) Infof

func (gl *GlueLogger) Infof(format string, args ...interface{})

func (*GlueLogger) Loud

func (gl *GlueLogger) Loud()

func (*GlueLogger) Quiet

func (gl *GlueLogger) Quiet()

func (*GlueLogger) Warn

func (gl *GlueLogger) Warn(msg interface{}, keyvals ...interface{})

func (*GlueLogger) Warnf

func (gl *GlueLogger) Warnf(format string, args ...interface{})

type GlueOptions

type GlueOptions struct {
	Selector string
	Verbose  bool
}

type GluePlugin

type GluePlugin struct {
	Name       string
	Brief      string
	Args       []runtime.ArgDef
	ReturnType runtime.Type
	Kind       PluginKind
}

A representation of a module Modules can be installed into the Lua state

type GlueScript

type GlueScript struct {
	Uri        string
	Type       ScriptType
	GroupStack []*GlueCodeGroup
	GroupNames []string
}

type GlueStack

type GlueStack struct {
	ExecutionStack []*GlueScript
}

func NewGlueScope

func NewGlueScope(fileName string) *GlueStack

func (*GlueStack) ActiveScript

func (scope *GlueStack) ActiveScript() *GlueScript

func (*GlueStack) AnnotateCurrentGroup

func (scope *GlueStack) AnnotateCurrentGroup(key string, value string)

func (*GlueStack) CurrentGroup

func (scope *GlueStack) CurrentGroup() *GlueCodeGroup

func (*GlueStack) GetActiveGroupAnnotation

func (scope *GlueStack) GetActiveGroupAnnotation(key string) string

func (*GlueStack) HasActiveScript

func (scope *GlueStack) HasActiveScript() bool

func (*GlueStack) PopGroup

func (scope *GlueStack) PopGroup()

func (*GlueStack) PopScript

func (scope *GlueStack) PopScript()

func (*GlueStack) PushGroup

func (scope *GlueStack) PushGroup(name string)

func (*GlueStack) PushScript

func (scope *GlueStack) PushScript(file string, kind ScriptType)

type GlueWriter

type GlueWriter struct {
	Loud      bool
	OutWriter io.Writer
}

func CreateGlueWriter

func CreateGlueWriter(std io.Writer) GlueWriter

func (GlueWriter) Write

func (gw GlueWriter) Write(p []byte) (n int, err error)

type Logger

type Logger interface {
	Info(msg interface{}, keyvals ...interface{})
	Infof(format string, args ...interface{})
	Debug(msg interface{}, keyvals ...interface{})
	Debugf(format string, args ...interface{})
	Warn(msg interface{}, keyvals ...interface{})
	Warnf(format string, args ...interface{})
	Error(msg interface{}, keyvals ...interface{})
	Errorf(format string, args ...interface{})
}

type Plan

type Plan interface {
	Execute() []error
	Step(name string, fn StepFunc)
	Add(plan Plan)
	Pretty() string
}

func NewPlan

func NewPlan(name string) Plan

type PluginKind

type PluginKind uint8
const (
	MODULE PluginKind = 1 << iota
	FUNCTION
)

type ScriptType

type ScriptType int
const (
	FILE ScriptType = 1 << iota
	STR
	REMOTE
)

type Selector

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

func NewSelector

func NewSelector(selector string) Selector

func NewSelectorWithPrefix

func NewSelectorWithPrefix(selector string, prefix []string) Selector

func (Selector) Test

func (selector Selector) Test(levels []string) (bool, error)

type StepFunc

type StepFunc func() error

type TestFunc

type TestFunc func()

type TestResult

type TestResult struct {
	Test  UnitTest
	Error error
}

type TestSuite

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

func (*TestSuite) RegisterTest

func (ts *TestSuite) RegisterTest(name string, fn TestFunc)

func (*TestSuite) Test

func (ts *TestSuite) Test()

func (*TestSuite) TestResults

func (ts *TestSuite) TestResults() []TestResult

func (*TestSuite) Testing

func (ts *TestSuite) Testing() bool

type Testable

type Testable interface {
	RegisterTest(name string, t TestFunc)
	Test()
	Testing() bool
	TestResults() []TestResult
}

func NewTestSuite

func NewTestSuite() Testable

type TreePlan

type TreePlan struct {
	Name     string `json:"name"`
	Fn       StepFunc
	Children []Plan `json:"children"`
}

func (*TreePlan) Add

func (step *TreePlan) Add(plan Plan)

func (*TreePlan) Execute

func (step *TreePlan) Execute() []error

func (*TreePlan) Pretty

func (step *TreePlan) Pretty() string

func (*TreePlan) Step

func (step *TreePlan) Step(name string, fn StepFunc)

type UnitTest

type UnitTest struct {
	Id   string
	Name string
	Fn   TestFunc
}

Jump to

Keyboard shortcuts

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