lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Luaprompt is an embeddable Lua command line prompt.  Any host application that uses Lua as an extension or configuration language can use it to incorporate an interactive prompt feature either for debugging or interactive use.  It should work with Lua versions 5.1 and 5.2.  Some features include:

* Command completion (via readline) of file names, keywords, global variables and table accesses (using either the dot, colon or angled bracket operators).
* Command history which can be saved accross sessions.
* Value inspection via pretty-printing of tables, strings, etc.  Care has been taken to make the output as readable as possible, for example by deciding how to format tables depending on whether they have an array part only or a hash part as well, what kind of values exist in the table, etc.
* Color highlighting (which can be disabled) of errors, stack traces and value printouts.

I know there are a couple such modules already available, but they're pure Lua implementations that augment the standard interpreter and therefore not suited for embedded use.  Currently luaprompt is not exported as a Lua module that can be imported via require to provide a prompt to pure Lua applications.  If users find such a feature useful it can be trivially added.

During the development of luaprompt I also noticed that there seems not to be any interpreters available other than the standard Lua interpreter which misses some of the features such interpreters usually have (perhaps they're not that necessary with Lua, which might explain why I only just noticed).  I've therefore implemented a standalone interpreter, named luap, on top of luaprompt with all the features described above.  It mimics the standard interpreter in most respects with the only difference that it's currently missing the -E switch (it was a bit of a hassle to support, but it can be implemented if necessary).  Luap can also serve as an example application of luaprompt.

Luaprompt is part of my main project but every care has been taken to make it as general-purpose as possible.  The project page can be found here:

http://www.nongnu.org/techne/lua/luaprompt/

It is currently distributed as a tarball only as I'm in the middle of switching to a new VCS and need to work out exactly how to support separate distributions of this and other such modules I'll be releasing.   Since it's possible/probable that the distribution mirrors won't have picked up the file yet so that the download links on the page above won't work I'm attaching the tarball here as well.  It's pretty small anyway.

Suggestions, bug reports and any sort of feedback is of course most welcome.

Dimitris

Attachment: luaprompt_0.1.tar.gz
Description: GNU Zip compressed data