From 9a74b811f007986a3e6015af0c06b33147d05951 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 17 Sep 2020 13:57:22 +0200 Subject: eval: implement -m option to preload modules The -m option instructs the interpreter to automatically require the named module and to register the module context as global variable. The following two commands are equivalent, with the former one serving as a shortcut for the latter: utpl -m fs -s '{{ fs.open("test.txt").read("all") }}' utpl -s '{% fs = require("fs"); print(fs.open("test.txt").read("all")) %}' Signed-off-by: Jo-Philipp Wich --- eval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'eval.h') diff --git a/eval.h b/eval.h index 090a4db..26f932f 100644 --- a/eval.h +++ b/eval.h @@ -43,6 +43,6 @@ struct json_object * ut_invoke(struct ut_state *, uint32_t, struct json_object *, struct json_object *, struct json_object *); enum ut_error_type -ut_run(struct ut_state *state, struct json_object *env); +ut_run(struct ut_state *state, struct json_object *env, struct json_object *modules); #endif -- cgit v1.2.3