nomsu/lib/secrets.nom

30 lines
793 B
Plaintext

require "lib/core.nom"
compile (with secrets %block) to block: ".."
|local secrets = {}
|\(%block as lua statements)
# Access the lua variable that should be within scope
compile (secrets) to: "secrets"
compile (secret %key; secret value of %key; secret value for %key) to:
assert ((%key's "type") == "Var") ".."
|Wrong type, expected Var, but got: \(%key's "type")
"secrets[\(repr (%key's "value"))]"
compile (secret %key = %new_value) to code:
assert ((%key's "type") == "Var") ".."
|Wrong type, expected Var, but got: \(%key's "type")
"secrets[\(repr (%key's "value"))] = \(%new_value as lua)"
with secrets:
secret %foo = 5
rule (plumb %) =:
secret %foo = %
rule (frop) =:
secret %foo
say (frop)
plumb 99
say (frop)