mirror of https://github.com/Hilbis/Hilbish
feat: oxalis experiments
parent
d46c079afb
commit
255f56d709
|
@ -47,3 +47,9 @@ end)
|
|||
bait.catch('hilbish.notification', function(notif)
|
||||
doNotifyPrompt()
|
||||
end)
|
||||
|
||||
local ops = require 'nature.oxalis.operators'
|
||||
getmetatable('').__bor = function(l, r)
|
||||
return ops.pipe(l, r)
|
||||
end
|
||||
hilbish.runner.setCurrent 'lua'
|
||||
|
|
9
exec.go
9
exec.go
|
@ -207,7 +207,7 @@ func runLuaRunner(runr rt.Value, userInput string) (input string, exitCode uint8
|
|||
func handleLua(input string) (string, uint8, error) {
|
||||
cmdString := aliases.Resolve(input)
|
||||
// First try to load input, essentially compiling to bytecode
|
||||
chunk, err := l.CompileAndLoadLuaChunk("", []byte(cmdString), rt.TableValue(l.GlobalEnv()))
|
||||
chunk, err := l.CompileAndLoadLuaChunkOrExp("", []byte(cmdString), rt.TableValue(l.GlobalEnv()))
|
||||
if err != nil && noexecute {
|
||||
fmt.Println(err)
|
||||
/* if lerr, ok := err.(*lua.ApiError); ok {
|
||||
|
@ -221,7 +221,12 @@ func handleLua(input string) (string, uint8, error) {
|
|||
// And if there's no syntax errors and -n isnt provided, run
|
||||
if !noexecute {
|
||||
if chunk != nil {
|
||||
_, err = rt.Call1(l.MainThread(), rt.FunctionValue(chunk))
|
||||
var ret rt.Value
|
||||
ret, err = rt.Call1(l.MainThread(), rt.FunctionValue(chunk))
|
||||
retStr, good := ret.ToString()
|
||||
if good {
|
||||
fmt.Println(retStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
local M = {}
|
||||
|
||||
function M.pipe(cmd, cmd2)
|
||||
--
|
||||
end
|
||||
|
||||
hilbish.runner.add('oxalis', {
|
||||
run = function(input)
|
||||
|
||||
end
|
||||
})
|
|
@ -0,0 +1,17 @@
|
|||
local fs = require 'fs'
|
||||
local M = {}
|
||||
|
||||
function M.pipe(cmd, cmd2)
|
||||
local pr, pw = fs.pipe()
|
||||
hilbish.run(cmd, {
|
||||
out = pw,
|
||||
err = pw,
|
||||
})
|
||||
pw:close()
|
||||
hilbish.run(cmd2, {
|
||||
input = pr
|
||||
})
|
||||
return {command = cmd2, input = pr, out }
|
||||
end
|
||||
|
||||
return M
|
Loading…
Reference in New Issue