2022-03-20 19:15:44 +00:00
|
|
|
package main
|
|
|
|
|
2022-03-28 02:14:53 +00:00
|
|
|
/*
|
2022-03-20 19:15:44 +00:00
|
|
|
import (
|
|
|
|
)
|
|
|
|
|
|
|
|
func runnerModeLoader(L *lua.LState) *lua.LTable {
|
|
|
|
exports := map[string]lua.LGFunction{
|
|
|
|
"sh": shRunner,
|
|
|
|
"lua": luaRunner,
|
|
|
|
"setMode": hlrunnerMode,
|
|
|
|
}
|
|
|
|
|
|
|
|
mod := L.SetFuncs(L.NewTable(), exports)
|
|
|
|
L.SetField(mod, "mode", runnerMode)
|
|
|
|
|
|
|
|
return mod
|
|
|
|
}
|
|
|
|
|
|
|
|
func shRunner(L *lua.LState) int {
|
|
|
|
cmd := L.CheckString(1)
|
|
|
|
exitCode, err := handleSh(cmd)
|
|
|
|
var luaErr lua.LValue = lua.LNil
|
|
|
|
if err != nil {
|
|
|
|
luaErr = lua.LString(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
L.Push(lua.LNumber(exitCode))
|
|
|
|
L.Push(luaErr)
|
|
|
|
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
|
|
|
func luaRunner(L *lua.LState) int {
|
|
|
|
cmd := L.CheckString(1)
|
|
|
|
exitCode, err := handleLua(cmd)
|
|
|
|
var luaErr lua.LValue = lua.LNil
|
|
|
|
if err != nil {
|
|
|
|
luaErr = lua.LString(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
L.Push(lua.LNumber(exitCode))
|
|
|
|
L.Push(luaErr)
|
|
|
|
|
|
|
|
return 2
|
|
|
|
}
|
2022-03-28 02:14:53 +00:00
|
|
|
*/
|