From e03e55fb7d5dff8f2c7e64e9b35afb26c4665a0b Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 13 Apr 2017 14:19:31 +1000 Subject: lua-cli: Create 'arg' table --- tests/manual-tests/lua-cli.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/manual-tests') 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; -- cgit v1.2.3-70-g09d2