aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-13 14:19:31 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-19 17:25:30 +1000
commite03e55fb7d5dff8f2c7e64e9b35afb26c4665a0b (patch)
tree0b310bab0e0faee05361cac37fbd1cfb1b28f223
parentd0b19d0a978b78d3fb4e6e5842af13736f58b316 (diff)
downloadfengari-e03e55fb7d5dff8f2c7e64e9b35afb26c4665a0b.tar.gz
fengari-e03e55fb7d5dff8f2c7e64e9b35afb26c4665a0b.tar.bz2
fengari-e03e55fb7d5dff8f2c7e64e9b35afb26c4665a0b.zip
lua-cli: Create 'arg' table
-rwxr-xr-xtests/manual-tests/lua-cli.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js
index e32067e..0b097f8 100755
--- a/tests/manual-tests/lua-cli.js
+++ b/tests/manual-tests/lua-cli.js
@@ -14,8 +14,18 @@ const _PROMPT2 = lua.to_luastring("_PROMPT2");
const L = lauxlib.luaL_newstate();
+let script = 2; // Where to start args from
+
linit.luaL_openlibs(L);
+/* create 'arg' table */
+lapi.lua_createtable(L, process.argv.length - (script + 1), script + 1);
+for (let i = 0; i < process.argv.length; i++) {
+ lapi.lua_pushliteral(L, process.argv[i]);
+ lapi.lua_seti(L, -2, i - script); /* TODO: rawseti */
+}
+lapi.lua_setglobal(L, lua.to_luastring("arg"));
+
let init = process.env["LUA_INIT"+lua.LUA_VERSUFFIX] || process.env["LUA_INIT"];
if (init) {
let status;