store

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package store holds scenario variables and performs ${name} expansion. Expansion is deliberately simple substitution — atago is not a programming language.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape added in v0.3.2

func Escape(s string) string

Escape rewrites text so that Expand returns it verbatim: it prefixes an extra `$` onto exactly the references Expand acts on — a live `${name}` becomes the literal `$${name}`, and an already-escaped `$${name}` becomes `$$${name}` — while a `${` that Expand ignores (one not followed by a valid name, e.g. `${1}` or `${}`) is left untouched, because Expand would already pass it through. It is the exact inverse Expand relies on, so raw observed text (a recorded command, output anchor, or typed pty input) can be embedded in a spec without being re-expanded at replay. A blind `${`→`$${` rewrite is wrong: the expander only unescapes `$${<valid-name>}`, so `$${1}` would never round-trip back to the observed `${1}`.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a per-scenario variable map.

func New

func New() *Store

New returns an empty Store.

func (*Store) Expand

func (s *Store) Expand(in string) string

Expand replaces ${name} references with stored values and ${env:NAME} references with host environment variables. Unknown references are left verbatim so they surface as obvious failures rather than empty strings.

func (*Store) ExpandMap

func (s *Store) ExpandMap(m map[string]string) map[string]string

ExpandMap returns a copy of m with all values expanded.

func (*Store) Get

func (s *Store) Get(name string) (string, bool)

Get returns a variable and whether it was set.

func (*Store) Set

func (s *Store) Set(name, value string)

Set assigns a variable.

func (*Store) Unresolved

func (s *Store) Unresolved(in string) []string

Unresolved returns the names of ${name} references in in that no stored variable resolves, and of ${env:NAME} references whose environment variable is not set. Escaped $${name} literals are not reported — the author explicitly asked for literal text. Callers use this to turn a reference that nothing could ever expand into an explained failure instead of passing the literal text on.

Jump to

Keyboard shortcuts

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