summaryrefslogtreecommitdiff
path: root/tests/manual-tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-13 12:46:03 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-19 17:25:25 +1000
commitcfd6ac4b61f3d175725620895120b7480056bafd (patch)
tree54e56049c8e3020de0216c6e033b8de116fe0737 /tests/manual-tests
parent9aedb17371c7d77b4577c496654b9edf8f5bddb1 (diff)
downloadfengari-cfd6ac4b61f3d175725620895120b7480056bafd.tar.gz
fengari-cfd6ac4b61f3d175725620895120b7480056bafd.tar.bz2
fengari-cfd6ac4b61f3d175725620895120b7480056bafd.zip
lua-cli: Add support for configurable prompts
Diffstat (limited to 'tests/manual-tests')
-rwxr-xr-xtests/manual-tests/lua-cli.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js
index f93f306..0b5519b 100755
--- a/tests/manual-tests/lua-cli.js
+++ b/tests/manual-tests/lua-cli.js
@@ -8,11 +8,9 @@ const linit = require('../../src/linit.js');
const fs = require('fs');
const readlineSync = require('readline-sync');
-readlineSync.setDefaultOptions({
- prompt: '> '
-});
-
const stdin = lua.to_luastring("=stdin");
+const _PROMPT = lua.to_luastring("_PROMPT");
+const _PROMPT2 = lua.to_luastring("_PROMPT2");
const L = lauxlib.luaL_newstate();
@@ -21,7 +19,11 @@ linit.luaL_openlibs(L);
console.log(lua.FENGARI_COPYRIGHT);
for (;;) {
- let input = readlineSync.prompt();
+ lapi.lua_getglobal(L, _PROMPT);
+ let input = readlineSync.prompt({
+ prompt: lapi.lua_tojsstring(L, -1) || '> '
+ });
+ lapi.lua_pop(L, 1);
if (input.length === 0)
continue;
@@ -41,9 +43,11 @@ for (;;) {
while (status === lua.thread_status.LUA_ERRSYNTAX && lapi.lua_tojsstring(L, -1).endsWith("<eof>")) {
/* continuation */
lapi.lua_pop(L, 1);
+ lapi.lua_getglobal(L, _PROMPT2);
input += "\n" + readlineSync.prompt({
- prompt: '>> '
+ prompt: lapi.lua_tojsstring(L, -1) || '>> '
});
+ lapi.lua_pop(L, 1);
let buffer = lua.to_luastring(input);
status = lauxlib.luaL_loadbuffer(L, buffer, buffer.length, stdin);
}