2022-03-20 19:15:44 +00:00
|
|
|
Hilbish is *unique,* when interactive it first attempts to run input as
|
|
|
|
Lua and then tries shell script. But if you're normal, you wouldn't
|
|
|
|
really be using Hilbish anyway but you'd also not want this
|
|
|
|
(or maybe want Lua only in some cases.)
|
|
|
|
|
|
|
|
The "runner mode" of Hilbish is customizable via `hilbish.runnerMode`,
|
|
|
|
which determines how Hilbish will run user input. By default, this is
|
|
|
|
set to `hybrid` which is the previously mentioned behaviour of running Lua
|
|
|
|
first then going to shell script. If you want the reverse order, you can
|
|
|
|
set it to `hybridRev` and for isolated modes there is `sh` and `lua`
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
You can also set it to a function, which will be called everytime Hilbish
|
|
|
|
needs to run interactive input. For example, you can set this to a simple
|
|
|
|
function to compile and evaluate Fennel, and now you can run Fennel.
|
|
|
|
You can even mix it with sh to make a hybrid mode with Lua replaced by
|
|
|
|
Fennel.
|
|
|
|
|
|
|
|
An example:
|
|
|
|
hilbish.runnerMode(function(input)
|
|
|
|
local ok = pcall(fennel.eval, input)
|
|
|
|
if ok then
|
2022-04-13 14:11:38 +00:00
|
|
|
return input, 0, nil
|
2022-03-20 19:15:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return hilbish.runner.sh(input)
|
|
|
|
end)
|
|
|
|
|
|
|
|
The `hilbish.runner` interface is an alternative to using `hilbish.runnerMode`
|
|
|
|
and also provides the sh and Lua runner functions that Hilbish itself uses.
|
2022-04-13 14:11:38 +00:00
|
|
|
A runner function is expected to return 3 values: the input, exit code, and an error.
|
|
|
|
The input return is there incase you need to prompt for more input.
|
|
|
|
If you don't, just return the input passed to the runner function.
|
2022-03-20 19:15:44 +00:00
|
|
|
The exit code has to be a number, it will be 0 otherwise and the error can be
|
|
|
|
`nil` to indicate no error.
|
2022-03-22 22:38:13 +00:00
|
|
|
|
|
|
|
## Functions
|
|
|
|
These are the functions for the `hilbish.runner` interface
|
|
|
|
|
|
|
|
+ setMode(mode) > The same as `hilbish.runnerMode`
|
2022-04-13 14:11:38 +00:00
|
|
|
+ sh(input) -> input, code, err > Runs `input` in Hilbish's sh interpreter
|
|
|
|
+ lua(input) -> input, code, err > Evals `input` as Lua code
|