lua-users home
lua-l archive

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


luaprompt is both an interactive Lua prompt that can be used instead
of the official interpreter, as well as a module that provides a Lua
command prompt that can be embedded in a host application.  As a
standalone interpreter it provides many conveniences that are missing
from the official Lua interpreter.  As an embedded prompt, 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.

luaprompt features:

* Readline-based input with history and completion: In particular all
  keywords, global variables and table accesses (with string or
  integer keys) can be completed in addition to readline's standard
  file completion.  Module names are also completed, for modules
  installed in the standard directories, and completed modules can
  optionally be loaded.

* Persistent command history (retained across sessions).

* Proper value pretty-printing for interactive use: When an expression
  is entered at the prompt, all returned values are printed
  (prepending with an equal sign is not required).  Values are printed
  in a descriptive way that tries to be as readable as possible.  The
  formatting tries to mimic Lua code (this is done to minimize
  ambiguities and no guarantees are made that it is valid code).
  Additionally, each value is stored in a table for future reference.

* Color highlighting of error messages and variable printouts.

This release includes a couple of improvements:

* luaprompt is now available as a module as well as a standalone executable and can be installed via luarocks. Just type

    luarocks install luaprompt

to get both the module and the standalone interpreter.

* Some completion-related improvements include the support for __index tables and better filename completion.

* luaprompt now saves the results of each command in a table, which by default is named "_". The use of the feature can most easily be explained by the following excerpt from a luap session:

>  io.open "/tmp/hello"
_[1] = file (0x113b110)
>  _[1]:read("*a")
_[2] = "Hello World\n"
>  _[1]:close()
_[3] = true
>  _
_[4] = { file (closed), "Hello World\n", true,  }
>

* luaprompt also works with Lua 5.3! Well, no actual change was required to get it to work, I just thought I'd mention it.

For more information, see the README at luaprompt's GitHub page, which you can find at the URL below:

https://github.com/dpapavas/luaprompt