luaprompt is a simple library that provides a Lua command prompt that can be embedded in a host application. It's meant for applications that use Lua as a configuration or interface language and can therefore benefit from an interactive prompt for debugging or regular use.
To embed luaprompt into a host application simply compile and link prompt.c with your sources. A POSIX environment is assumed and readline is required for proper command line editing. If readline is provided you should define the macros HAVE_LIBREADLINE and either HAVE_READLINE_READLINE_H or HAVE_READLINE_H depending on where your readline's header files are installed . Similar macros are required for command line history support. See the example Makefile for details. You can use luaprompt with both Lua 5.1 and 5.2.
The API is very simple:
void luap_enter (lua_State *L);
Call this to begin an interactive session. The session can be terminated with Ctrl-D.
void luap_setname (lua_State *L, const char *name);
Set the name of the application. This is basically the chunk name displayed with error messages. The default program name is "lua".
void luap_setprompts (lua_State *L, const char *single, char *multi);
Provide two prompts, one for single-line and one for multi-line input. The defaults prompts are "> " and ">> ".
void luap_sethistory (lua_State *L, const char *file);
Set the file to be used to perist the command history across sessions. If this function isn't called the command history is lost on session exit. The provided name is fully expanded as if it was entered at the shell so you can use a string of the form "~/.lua_history" for examle.
void luap_setcolor (lua_State *L, int enable);
Setting enable to zero disables color output. Color output is enabled by default if the output has not been redirected to a file or pipe.
In addition to the above the following calls, which are meant for internal use can be used by the host applicaton as well if required.
char *luap_describe (lua_State *L, int index);
Returns a string with a human-readable serialization of the value at the specified index.
int luap_call (lua_State *L, int n);
Calls a function with n arguments and provides a stack trace on error. This equivalent to calling lua_pcall with LUA_MULTRET.
Although luaprompt is meant for embedded use a standalone interpreter, named luap, has been written as well which tries to mimic the standard lua interepreter as much as possible (currently only the -E flag is not supported) while providing the extra set of features described above. Some tweaking of the makefile may be required to get it to build.
The latest version of luaprompt is 0.3, released on August the 14th 2013. You can download the source here.
luaprompt is released under the terms and conditions of the MIT/X11 license.
 These macros are needed because the host project uses a specific autoconf macro to test for readline presence.