Documentation
¶
Overview ¶
This package provides default implementations of commands that can be used when creating modules.
Index ¶
- type Commands
- func (self *Commands) Env(name string, args *EnvArgs) (interface{}, error)
- func (self *Commands) Fail(message string) error
- func (self *Commands) Log(message interface{}) error
- func (self *Commands) Put(value interface{}) (interface{}, error)
- func (self *Commands) Run(filename string, args *RunArgs) (interface{}, error)
- func (self *Commands) Wait(delay interface{}) error
- type EnvArgs
- type RunArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commands ¶
func (*Commands) Env ¶
Retrieves a system environment variable and returns the value of it, or a fallback value if the variable does not exist or (optionally) is empty.
#### Examples
##### Get the value of the `USER` environment variable and store it ``` env 'USER' -> $user ```
##### Require the `LANG`, `USER`, and `CI` environment variables; and fail they are not set. ``` env 'LANG' { required: true } env 'USER' { required: true } env 'CI' { required: true } ```
func (*Commands) Fail ¶
Immediately exit the script in an error-like fashion with a specific message.
func (*Commands) Put ¶
Store a value in the current scope. Strings will be automatically converted into the appropriate data types (float, int, bool) if possible.
func (*Commands) Run ¶
Evaluates another Friendscript loaded from another file. The filename is the absolute path or basename of the file to search for in the FRIENDSCRIPT_PATH environment variable to load and evaluate. The FRIENDSCRIPT_PATH variable behaves like the the traditional *nix PATH variable, wherein multiple paths can be specified as a colon-separated (:) list. The directory of the calling script (if available) will always be checked first.
Returns: The value of the variable named by result_key at the end of the evaluated script's execution.
type EnvArgs ¶
type EnvArgs struct { // The value to return if the environment variable does not exist, or // (optionally) is empty. Fallback interface{} `json:"fallback"` // Whether empty values should be ignored or not. Required bool `json:"required" default:"false"` // Whether automatic type detection should be performed or not. DetectType bool `json:"detect_type" default:"true"` // If specified, this string will be used to split matching values into a // list of values. This is useful for environment variables that contain // multiple values joined by a separator (e.g: the PATH variable.) Joiner string `json:"joiner"` }
type RunArgs ¶
type RunArgs struct { // 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_key"` // result // Provides a set of initial variables to the script. Data map[string]interface{} `json:"data"` // null // If true, the scope of the running script will not be able to modify data in the parent scope. Isolated bool `json:"isolated" default:"true"` }