vars

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Variables

type Variables struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Variables stores a variable map that used for variable expansion in parsed commands and other parsed strings.

func New

func New() *Variables

New construction function to create a new Variables

func (*Variables) Envs

func (v *Variables) Envs(val string) *Variables

Envs declares process environment variables using a multi-line space-separated list of KEY=VAL format: i.e. GOOS=linux GOARCH=amd64

func (*Variables) Err

func (v *Variables) Err() error

Err surfaces Variables error

func (*Variables) Eval

func (v *Variables) Eval(str string) string

Eval returns the string str with its content expanded with variable values i.e. Eval("I am $HOME") returns "I am </user/home/path>"

func (*Variables) ExpandVar

func (v *Variables) ExpandVar(str string, expandFunc func(string) string) string

ExpandVar searches str for $value or ${value} which is then evaluated using os.ExpandEnv. If variable starts with <escapeChar>$, the expansion sequence will be ignored. For instance if the escapeChar is '\', when \$value or \${value} is encountered, the variable expansion is ignored leaving the original values in the string as $value or ${value}.

func (*Variables) SetEnv

func (v *Variables) SetEnv(name, value string) *Variables

SetEnv sets a process environment variable.

func (*Variables) SetVar

func (v *Variables) SetVar(name, value string) *Variables

SetVar declares an in-process local variable.

func (*Variables) UnsetVar added in v0.3.0

func (v *Variables) UnsetVar(name string) *Variables

UnsetVar removes a previously set local variable.

func (*Variables) Val

func (v *Variables) Val(name string) string

Val searches for a Var with provided key, if not found searches for environment var, for running process, with same key

func (*Variables) Vars

func (v *Variables) Vars(val string) *Variables

Vars declares an internal variable used during current gexe session. It uses a multi-line, space-separated list of KEY=VAL format: i.e. foo=bar fuzz=buzz

func (*Variables) WithEscapeChar

func (v *Variables) WithEscapeChar(r rune) *Variables

WithEscapeChar sets the espacape char for the variable

Jump to

Keyboard shortcuts

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