bakpakin / Fennel

Lua Lisp Language
https://fennel-lang.org
MIT License
2.43k stars 124 forks source link

Adding readline support for the REPL public API #418

Closed gbaptista closed 2 years ago

gbaptista commented 2 years ago

Today, if you start a REPL through the fennel command, it will add readline support, if available.

But, if you start the REPL through the public API, e.g.:

fennel -e "(let [f (require :fennel)] (f.repl {}))"

Or try to start a REPL inside some part of your code:

(local fennel (require :fennel))

(fennel.repl {})

The readline support won't be added, even if you have it available.

This PR moves the try-readline function from launcher.fnl to repl.fnl so that both ways add readline support.

If the user provides readChunk or registerCompleter, It will not add readline support to avoid interfering with the desired customization.

Also, it removes the requirement of the options parameter when starting a REPL: I found no reason to be something mandatory.

technomancy commented 2 years ago

Looks good; thanks!