Documentation
¶
Index ¶
- Constants
- Variables
- type ContextHandlerFunc
- type Environment
- func (self *Environment) Commands() []string
- func (self *Environment) DisableCommand(module string, cmdname string)
- func (self *Environment) EnableCommand(module string, cmdname string)
- func (self *Environment) Evaluate(script *scripting.Friendscript, scope ...*scripting.Scope) (*scripting.Scope, error)
- func (self *Environment) EvaluateFile(path string, scope ...*scripting.Scope) (*scripting.Scope, error)
- func (self *Environment) EvaluateReader(reader io.Reader, scope ...*scripting.Scope) (*scripting.Scope, error)
- func (self *Environment) EvaluateString(data string, scope ...*scripting.Scope) (*scripting.Scope, error)
- func (self *Environment) Get(key string, fallback ...interface{}) interface{}
- func (self *Environment) Module(name string) (Module, bool)
- func (self *Environment) Modules() map[string]Module
- func (self *Environment) MustModule(name string) Module
- func (self *Environment) REPL() (*scripting.Scope, error)
- func (self *Environment) RegisterCommandHandler(command string, handler InteractiveHandlerFunc) error
- func (self *Environment) RegisterContextHandler(handler ContextHandlerFunc) int
- func (self *Environment) RegisterModule(prefix string, module Module)
- func (self *Environment) Run(scriptName string, options *utils.RunOptions) (interface{}, error)
- func (self *Environment) Scope() *scripting.Scope
- func (self *Environment) Set(key string, value interface{})
- func (self *Environment) SetData(data map[string]interface{})
- func (self *Environment) UnregisterContextHandler(id int)
- func (self *Environment) UnregisterModule(prefix string)
- type InteractiveContext
- type InteractiveHandlerFunc
- type Module
Constants ¶
const DefaultEnvironmentName = `friendscript`
const Version = `0.7.7`
Variables ¶
var MaxReaderWait = time.Duration(5) * time.Second
Functions ¶
This section is empty.
Types ¶
type ContextHandlerFunc ¶
type Environment ¶
type Environment struct { Name string // contains filtered or unexported fields }
func NewEnvironment ¶
func NewEnvironment(data ...map[string]interface{}) *Environment
Create a new scripting environment.
func (*Environment) Commands ¶
func (self *Environment) Commands() []string
List all commands supported by all registered modules.
func (*Environment) DisableCommand ¶
func (self *Environment) DisableCommand(module string, cmdname string)
Specify a command that should not be permitted to execute.
func (*Environment) EnableCommand ¶
func (self *Environment) EnableCommand(module string, cmdname string)
Specify a command that should be permitted to execute.
func (*Environment) Evaluate ¶
func (self *Environment) Evaluate(script *scripting.Friendscript, scope ...*scripting.Scope) (*scripting.Scope, error)
func (*Environment) EvaluateFile ¶
func (*Environment) EvaluateReader ¶
func (*Environment) EvaluateString ¶
func (*Environment) Get ¶
func (self *Environment) Get(key string, fallback ...interface{}) interface{}
func (*Environment) Module ¶
func (self *Environment) Module(name string) (Module, bool)
Retrieve the named module.
func (*Environment) Modules ¶
func (self *Environment) Modules() map[string]Module
Retrieve a copy of the currently registered modules.
func (*Environment) MustModule ¶
func (self *Environment) MustModule(name string) Module
Retrieve the named module, or panic if it is not registered.
func (*Environment) RegisterCommandHandler ¶
func (self *Environment) RegisterCommandHandler(command string, handler InteractiveHandlerFunc) error
Registers a function to handle a specific REPL command. If command is an empty string, the function will be called for each command entered into the REPL.
func (*Environment) RegisterContextHandler ¶
func (self *Environment) RegisterContextHandler(handler ContextHandlerFunc) int
Registers a handler that will receive updates on execution context and state as the script is running. Will return an integer that can be used to remove the handler at a later point.
func (*Environment) RegisterModule ¶
func (self *Environment) RegisterModule(prefix string, module Module)
Registers a command module to the given prefix. If a module with the same prefix already exists, it will be replaced with the given module. Prefixes will be stripped of spaces and converted to snake_case. If an empty prefix is given, the default UnqualifiedModuleName ("core") will be used.
func (*Environment) Run ¶
func (self *Environment) Run(scriptName string, options *utils.RunOptions) (interface{}, error)
func (*Environment) Scope ¶
func (self *Environment) Scope() *scripting.Scope
func (*Environment) Set ¶
func (self *Environment) Set(key string, value interface{})
func (*Environment) SetData ¶
func (self *Environment) SetData(data map[string]interface{})
func (*Environment) UnregisterContextHandler ¶
func (self *Environment) UnregisterContextHandler(id int)
Remove the context handler with the given ID.
func (*Environment) UnregisterModule ¶
func (self *Environment) UnregisterModule(prefix string)
Removes a registered module at the given prefix.
type InteractiveContext ¶
type InteractiveHandlerFunc ¶
type InteractiveHandlerFunc func(ctx *InteractiveContext, environment *Environment) ([]string, error)
Directories
¶
Path | Synopsis |
---|---|
commands
|
|
assert
Suite of testing-oriented commands that will trigger errors or failures if they aren't satistifed.
|
Suite of testing-oriented commands that will trigger errors or failures if they aren't satistifed. |
core
This package provides default implementations of commands that can be used when creating modules.
|
This package provides default implementations of commands that can be used when creating modules. |
file
Commands for reading and writing files.
|
Commands for reading and writing files. |
fmt
Suite of string formatting utilities.
|
Suite of string formatting utilities. |
http
Commands for interacting with HTTP resources
|
Commands for interacting with HTTP resources |
utils
Contains miscellaneous utility commands.
|
Contains miscellaneous utility commands. |
vars
Commands for manipulating the current Friendscript variable scope.
|
Commands for manipulating the current Friendscript variable scope. |
examples
|
|