Make Lua's "exit" function a little prettier

"exit" now has a custom __tostring method, which prints an explanation
message. This is very similar to how Python achives the same
functionality:

    lua> exit
    Call exit() to exit
    lua> exit()
    > Actually leaves the REPL
This commit is contained in:
SquidDev 2019-12-29 18:49:35 +00:00
parent 041cfe91b4
commit 42f5389fb8
1 changed files with 4 additions and 3 deletions

View File

@ -9,9 +9,10 @@ end
local bRunning = true
local tCommandHistory = {}
local tEnv = {
["exit"] = function()
bRunning = false
end,
["exit"] = setmetatable({}, {
__tostring = function() return "Call exit() to exit" end,
__call = function() bRunning = false end,
}),
["_echo"] = function( ... )
return ...
end,