feat: oxalis experiments

oxalis
sammyette 2024-04-27 23:39:54 -04:00
parent d46c079afb
commit 255f56d709
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
4 changed files with 41 additions and 2 deletions

View File

@ -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'

View File

@ -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 {

View File

@ -0,0 +1,11 @@
local M = {}
function M.pipe(cmd, cmd2)
--
end
hilbish.runner.add('oxalis', {
run = function(input)
end
})

View File

@ -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