starbind

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeLoad

func MakeLoad() func(thread *starlark.Thread, module string) (starlark.StringDict, error)

MakeLoad returns a simple sequential implementation of module loading suitable for use in the REPL. Each function returned by MakeLoad accesses a distinct private cache.

Types

type Context

type Context interface {
	Client() service.Client
	RegisterCommand(name, helpMsg string, cmdfn func(args string) error)
	CallCommand(cmdstr string) error
	Scope() api.EvalScope
	LoadConfig() api.LoadConfig
}

Context is the context in which starlark scripts are evaluated. It contains methods to call API functions, command line commands, etc.

type EchoWriter added in v1.8.1

type EchoWriter interface {
	io.Writer
	Echo(string)
	Flush()
}

type Env

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

Env is the environment used to evaluate starlark scripts.

func New

func New(ctx Context, out EchoWriter) *Env

New creates a new starlark binding environment.

func (*Env) Cancel

func (env *Env) Cancel()

Cancel cancels the execution of a currently running script or function.

func (*Env) Execute

func (env *Env) Execute(path string, source interface{}, mainFnName string, args []interface{}) (starlark.Value, error)

Execute executes a script. Path is the name of the file to execute and source is the source code to execute. Source can be either a []byte, a string or a io.Reader. If source is nil Execute will execute the file specified by 'path'. After the file is executed if a function named mainFnName exists it will be called, passing args to it.

func (*Env) REPL

func (env *Env) REPL() error

REPL executes a read, eval, print loop.

func (*Env) Redirect added in v1.8.1

func (env *Env) Redirect(out EchoWriter)

Redirect redirects starlark output to out.

Jump to

Keyboard shortcuts

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