pass service to output
fn in output-template
All checks were successful
build liminix / build_vm_qemu_mips (pull_request) Successful in 33s
All checks were successful
build liminix / build_vm_qemu_mips (pull_request) Successful in 33s
instead of on command line
This commit is contained in:
parent
87e1fa128a
commit
1896d9d70c
12 changed files with 10 additions and 9 deletions
|
@ -1,3 +1,3 @@
|
||||||
check:
|
check:
|
||||||
./output-template ./example-output/ '{{' '}}' < example.ini > output
|
./output-template '{{' '}}' < example.ini > output
|
||||||
diff -u output example.ini.expected
|
diff -u output example.ini.expected
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
wpa_passphrase={{ secret "colours/black" }}
|
wpa_passphrase={{ output("./example-service","colours/black") }}
|
||||||
think = {{ string.format("%q", secret("colours/blue")) }}
|
think = {{ string.format("%q", output("./example-service","colours/blue")) }}
|
||||||
argonaut = {{ json_quote "hello\ngoodbye\tnext\027" }}
|
argonaut = {{ json_quote "hello\ngoodbye\tnext\027" }}
|
||||||
|
|
|
@ -20,11 +20,14 @@
|
||||||
(fn [x] (string.format "\\u%04X" (string.byte x))))))
|
(fn [x] (string.format "\\u%04X" (string.byte x))))))
|
||||||
|
|
||||||
|
|
||||||
(fn substitute [text service opening closing]
|
(fn substitute [text opening closing]
|
||||||
(let [delim (.. opening "(.-)" closing)
|
(let [delim (.. opening "(.-)" closing)
|
||||||
myenv {
|
myenv {
|
||||||
: string
|
: string
|
||||||
:secret (fn [x] (service:output x))
|
:output
|
||||||
|
(fn [service-path path]
|
||||||
|
(let [s (assert (svc.open (.. service-path "/.outputs")))]
|
||||||
|
(s:output path)))
|
||||||
:lua_quote #(string.format "%q" %1)
|
:lua_quote #(string.format "%q" %1)
|
||||||
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
|
:json_quote (fn [x] (.. "\"" (json-escape x) "\""))
|
||||||
}]
|
}]
|
||||||
|
@ -34,10 +37,8 @@
|
||||||
(string.format "missing value for %q" x))))))
|
(string.format "missing value for %q" x))))))
|
||||||
|
|
||||||
(fn run []
|
(fn run []
|
||||||
(let [[service-dir opening closing] arg
|
(let [[opening closing] arg
|
||||||
service (assert (svc.open service-dir))
|
out (substitute (: (io.input) :read "*a") opening closing)]
|
||||||
out (substitute (: (io.input) :read "*a") service opening closing)]
|
|
||||||
(io.write out)))
|
(io.write out)))
|
||||||
|
|
||||||
|
|
||||||
{ : run }
|
{ : run }
|
||||||
|
|
Loading…
Reference in a new issue