Skip to content

Commit

Permalink
feat: oxalis experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
TorchedSammy committed Apr 28, 2024
1 parent d46c079 commit 255f56d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .hilbishrc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 7 additions & 2 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions nature/oxalis/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local M = {}

function M.pipe(cmd, cmd2)
--
end

hilbish.runner.add('oxalis', {
run = function(input)

end
})
17 changes: 17 additions & 0 deletions nature/oxalis/operators.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 255f56d

Please sign in to comment.