interp

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(val any, vars map[string]string) any

Apply recursively replaces {{key}} in all string values of val using vars. {{env.NAME}} is resolved directly from the calling process environment. Non-string leaves (int, bool, float64) pass through unchanged.

func Grab

func Grab(jsonText, path string) (string, error)

Grab extracts a value from JSON text using a gjson path.

The leading dot convention from Ocarina's original syntax is preserved: ".0.sha" and "0.sha" both work. The full gjson path syntax is supported:

".name"                       — object key
".0"                          — array index
".items.0.title"              — nested path
"#[state==\"open\"].title"    — filter: first match
"#[state==\"open\"]#.title"   — filter: all matches
"#.name"                      — wildcard: all name values

func PyReprToJSON

func PyReprToJSON(s string) string

PyReprToJSON converts Python dict/list repr to JSON. Some MCP servers (e.g. mcp-server-sqlite) return str() of Python objects rather than JSON. Only handles the common case where string values contain no embedded single quotes. Returns "" if s doesn't look like a Python list/dict.

func StringMap

func StringMap(m map[string]string, vars map[string]string) map[string]string

StringMap applies vars to each value of a string map.

func Strings

func Strings(ss []string, vars map[string]string) []string

Strings applies vars to each element of a string slice.

func Unresolved

func Unresolved(val any) []string

Unresolved returns the distinct {{var}} references still present in val after Apply, i.e. references that no key or prior echo: defined. Callers use it to fail a step rather than silently send literal braces to a tool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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