Documentation ¶
Index ¶
- type Variables
- func (v *Variables) Envs(variables ...string) *Variables
- func (v *Variables) Err() error
- func (v *Variables) Eval(str string) string
- func (v *Variables) ExpandVar(str string, expandFunc func(string) string) string
- func (v *Variables) SetEnv(key, value string) *Variables
- func (v *Variables) SetVar(name, value string) *Variables
- func (v *Variables) UnsetVar(name string) *Variables
- func (v *Variables) Val(key string) string
- func (v *Variables) Vars(variables ...string) *Variables
- func (v *Variables) WithEscapeChar(r rune) *Variables
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Variables ¶
Variables stores a variable map that used for variable expansion in parsed commands and other parsed strings.
func (*Variables) Envs ¶
Envs declares process environment variables with support for variable expansion. Each variable must use the form:
<key-name>=<value>
With no space between key name, equal sign, and value, i.e. Envs(`GOOS=linux`, `GOARCH=amd64`, `INFO="OS: ${GOOS}, ARC: ${GOARCH}"`)
func (*Variables) Eval ¶
Eval returns the string str with its content expanded with variable references i.e. Eval("I am $HOME") returns "I am </user/home/path>"
func (*Variables) ExpandVar ¶
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) UnsetVar ¶ added in v0.3.0
UnsetVar removes a previously set gexe session variable.
func (*Variables) Val ¶
Val searches for a gexe session variable with provided key, if not found searches for an environment variable with that key.
func (*Variables) Vars ¶
Vars declares gexe session variables with support for variable expansion. Each variable must use the form:
<key-name>=<value>
With no space between key name, equal sign, and value, i.e. Vars(`foo=bar`, `fuzz=${foo}`, `dazz="this is ${fuzz}"`)
func (*Variables) WithEscapeChar ¶
WithEscapeChar sets the espacape char for the variable