vars

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: LGPL-2.1 Imports: 7 Imported by: 0

Documentation

Overview

Commands for manipulating the current Friendscript variable scope.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	utils.Module
	// contains filtered or unexported fields
}

func New

func New(env utils.Runtime) *Commands

func (*Commands) Clear

func (self *Commands) Clear(key string)

Unset the value at the given key.

func (*Commands) Ensure

func (self *Commands) Ensure(key string, args *EnsureArgs) error

Emit an error if the given key does not exist, optionally with a user-specified message.

func (*Commands) Get

func (self *Commands) Get(key string, args *GetArgs) (interface{}, error)

Return the value of a specific variable defined in a scope.

func (*Commands) Interpolate

func (self *Commands) Interpolate(format string, args *InterpolateArgs) (string, error)

Return a value interpolated with values from a scope or ones that are explicitly provided.

func (*Commands) Keys

func (self *Commands) Keys() ([]string, error)

Return a sorted list of all variable names in the current scope.

func (*Commands) Pop

func (self *Commands) Pop(key string) (interface{}, error)

Take the last value from the array at key. If key is an array, the last value of that array will be returned and the remainder will be left at key. Empty arrays will return nil and be unset. Non-array values will be returned and the key will be unset.

func (*Commands) Push

func (self *Commands) Push(key string, args *PushArgs) error

Push the given value onto the array at the specified key, creating the array if not present, and converting the existing value into an array already set to non-array value.

func (*Commands) Set

func (self *Commands) Set(key string, args *SetArgs) (interface{}, error)

Set the named variable to the given value, optionally interpolating variables from the current scope into the variable.

type EnsureArgs

type EnsureArgs struct {
	Message string `json:"message"`
}

type GetArgs

type GetArgs struct {
	Fallback interface{} `json:"fallback"`
}

type InterpolateArgs

type InterpolateArgs struct {
	Values interface{} `json:"values"`
}

type PushArgs

type PushArgs struct {
	Value interface{} `json:"value"`
}

type SetArgs

type SetArgs struct {
	Value       interface{} `json:"value"`
	Interpolate bool        `json:"interpolate" default:"true"`
}

Jump to

Keyboard shortcuts

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