grol-io / grol

Go REPL Open Language
https://grol.io
Apache License 2.0
22 stars 2 forks source link

Optional ClientData and Help for extensions, PreInput hook so per interp client data can be set, expose Extensions #178

Closed ldemailly closed 2 months ago

ldemailly commented 2 months ago

Needed (https://github.com/grol-io/grol-discord-bot/pull/83 which 'tests' this) to make grol discord bot safer for sending complex messages where the channelID is attached to the ClientData and thus can't be modified by grol code

Extensions can be changed/set using now exposed Extensions in the state.

Improves on extensions discoverable help; eg:

$ json_go  
json_go(any, [string]) // optional indent e.g json_go(m, "  ")
$ save
save([string]) // filename (.gr)

Through optional Help field

And client data replaces the default eval.State first argument in CallBack

Also adding repl.EvalStringOptions() which has the necessary starting values for EvalStringWithOptions to function.

ldemailly commented 2 months ago

I have more stuff I want to change/fix but will merge this one first and make smaller additional PRs