Documentation
¶
Index ¶
- func CallCommandFunction(from any, name string, first any, rest map[string]any) (any, error)
- func GetFunctionByName(from any, name string) (reflect.Value, error)
- func ListModuleCommands(module Module, skipNames ...string) []string
- type DefaultExecutor
- type Module
- type PathReaderFunc
- type PathWriterFunc
- type RunOptions
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallCommandFunction ¶
CallCommandFunction is where the process of turning Friendscript commands+parameters into Golang function calls happens. This is what the function does:
This Friendscript:
http::get "https://example.com" {
headers: {
"User-Agent": "friendscript",
},
}
...is executed as if it were:
httpModule.Get("https://example.com", &RequestArgs{
Headers: map[string]any{
"User-Agent": "friendscript",
},
})
func ListModuleCommands ¶
Types ¶
type DefaultExecutor ¶
type DefaultExecutor struct {
// contains filtered or unexported fields
}
func NewDefaultExecutor ¶
func NewDefaultExecutor(from any) *DefaultExecutor
func (*DefaultExecutor) ExecuteCommand ¶
func (*DefaultExecutor) FormatCommandName ¶
func (self *DefaultExecutor) FormatCommandName(name string) string
func (*DefaultExecutor) SetInstance ¶
func (self *DefaultExecutor) SetInstance(from any)
type PathReaderFunc ¶ added in v0.8.0
type PathReaderFunc = func(string) (io.ReadCloser, error)
type RunOptions ¶ added in v0.7.0
type RunOptions struct {
// If true, the scope of the running script will not inherit values from the calling scope.
Isolated bool `json:"isolated"`
// Specifies a key in the scope of the evaluate script that will be used as the result value of this command.
ResultKey string `json:"result"`
// Provides a set of initial variables to the script.
Data map[string]any `json:"data"`
// Sets the base path from which relative file lookups will be performed
BasePath string `json:"-"`
}
type Runtime ¶ added in v0.8.0
type Runtime interface {
Scope() *scripting.Scope
Run(scriptName string, options *RunOptions) (any, error)
GetReaderForPath(path string) (io.ReadCloser, error)
GetWriterForPath(path string) (string, io.Writer, error)
RegisterPathWriter(handler PathWriterFunc)
RegisterPathReader(handler PathReaderFunc)
Open(fileOrReader any) (io.ReadCloser, error)
}
Click to show internal directories.
Click to hide internal directories.