fix: typos, set default runner to lua implemented hybrid, add back hilbish.runner.sh

snail
sammyette 2024-12-29 01:36:33 -04:00
parent 16ddb85b4f
commit 55e879bd02
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 9 additions and 4 deletions

View File

@ -82,7 +82,7 @@ func (s *snail) Run(cmd string, strms *util.Streams) (bool, io.Writer, io.Writer
_, argstring := splitInput(strings.Join(args, " ")) _, argstring := splitInput(strings.Join(args, " "))
// i dont really like this but it works // i dont really like this but it works
aliases := make(map[string]string) aliases := make(map[string]string)
aliasesLua, _ := util.DoString(s.runtime, "return hilbish.aliases.all()") aliasesLua, _ := util.DoString(s.runtime, "return hilbish.aliases.list()")
util.ForEach(aliasesLua.AsTable(), func(k, v rt.Value) { util.ForEach(aliasesLua.AsTable(), func(k, v rt.Value) {
aliases[k.AsString()] = v.AsString() aliases[k.AsString()] = v.AsString()
}) })
@ -115,7 +115,7 @@ func (s *snail) Run(cmd string, strms *util.Streams) (bool, io.Writer, io.Writer
cmds := make(map[string]*rt.Closure) cmds := make(map[string]*rt.Closure)
luaCmds := util.MustDoString(s.runtime, "local commander = require 'commander'; return commander.registry()").AsTable() luaCmds := util.MustDoString(s.runtime, "local commander = require 'commander'; return commander.registry()").AsTable()
util.ForEach(luaCmds, func(k, v rt.Value) { util.ForEach(luaCmds, func(k, v rt.Value) {
cmds[k.AsString()] = k.AsTable().Get(rt.StringValue("exec")).AsClosure() cmds[k.AsString()] = v.AsTable().Get(rt.StringValue("exec")).AsClosure()
}) })
if cmd := cmds[args[0]]; cmd != nil { if cmd := cmds[args[0]]; cmd != nil {
stdin := sink.NewSinkInput(s.runtime, hc.Stdin) stdin := sink.NewSinkInput(s.runtime, hc.Stdin)

View File

@ -83,6 +83,11 @@ function hilbish.runner.getCurrent()
return currentRunner return currentRunner
end end
local snaili = snail.new()
function hilbish.runner.sh(input)
return snaili:run(input)
end
hilbish.runner.add('hybrid', function(input) hilbish.runner.add('hybrid', function(input)
local cmdStr = hilbish.aliases.resolve(input) local cmdStr = hilbish.aliases.resolve(input)
@ -109,5 +114,5 @@ hilbish.runner.add('lua', function(input)
return hilbish.runner.lua(cmdStr) return hilbish.runner.lua(cmdStr)
end) end)
hilbish.runner.add('sh', snail.new()) hilbish.runner.add('sh', hilbish.runner.sh)
hilbish.runner.setCurrent 'hybrid'