summaryrefslogtreecommitdiff
path: root/utils/hwstub/tools/hwstub_shell.cpp
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2015-06-28 17:51:43 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2015-06-28 17:55:17 +0200
commite70ea5d21ff1aca5b8c534da8f3a1ccadd330a2e (patch)
tree611750d6bd70f20585801cfd7e8c441180798bee /utils/hwstub/tools/hwstub_shell.cpp
parent465eb727a30fd1f4470ff6c172f7b41856775167 (diff)
downloadrockbox-e70ea5d21ff1aca5b8c534da8f3a1ccadd330a2e.zip
rockbox-e70ea5d21ff1aca5b8c534da8f3a1ccadd330a2e.tar.gz
rockbox-e70ea5d21ff1aca5b8c534da8f3a1ccadd330a2e.tar.bz2
rockbox-e70ea5d21ff1aca5b8c534da8f3a1ccadd330a2e.tar.xz
hwstub: Add completion and some pretty printing to the shell
This uses slightly hacked luaprompt to provide all the goodis. See https://github.com/dpapavas/luaprompt for original. Change-Id: Iedddb79abae5809299322bc215722dd928c35cca
Diffstat (limited to 'utils/hwstub/tools/hwstub_shell.cpp')
-rw-r--r--utils/hwstub/tools/hwstub_shell.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp
index 8b7a8b9..f59ca8b 100644
--- a/utils/hwstub/tools/hwstub_shell.cpp
+++ b/utils/hwstub/tools/hwstub_shell.cpp
@@ -29,6 +29,9 @@
#include <lua.hpp>
#include <unistd.h>
#include "soc_desc.hpp"
+extern "C" {
+#include "prompt.h"
+}
#if LUA_VERSION_NUM < 502
#warning You need at least lua 5.2
@@ -941,21 +944,8 @@ int main(int argc, char **argv)
printf("error: %s\n", lua_tostring(g_lua, -1));
}
- // use readline to provide some history and completion
- rl_bind_key('\t', rl_complete);
- while(!g_exit)
- {
- char *input = readline("> ");
- if(!input)
- break;
- add_history(input);
- // evaluate string
- if(luaL_dostring(g_lua, input))
- printf("error: %s\n", lua_tostring(g_lua, -1));
- // pop everything to start from a clean stack
- lua_pop(g_lua, lua_gettop(g_lua));
- free(input);
- }
+ // start interactive shell
+ luap_enter(g_lua, &g_exit);
Lerr:
// display log if handled