From 55e879bd028f4004d031955b1c59230afcd43e93 Mon Sep 17 00:00:00 2001 From: sammyette Date: Sun, 29 Dec 2024 01:36:33 -0400 Subject: [PATCH] fix: typos, set default runner to lua implemented hybrid, add back hilbish.runner.sh --- golibs/snail/snail.go | 4 ++-- nature/runner.lua | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/golibs/snail/snail.go b/golibs/snail/snail.go index 4ef92ea..ddfef49 100644 --- a/golibs/snail/snail.go +++ b/golibs/snail/snail.go @@ -82,7 +82,7 @@ func (s *snail) Run(cmd string, strms *util.Streams) (bool, io.Writer, io.Writer _, argstring := splitInput(strings.Join(args, " ")) // i dont really like this but it works 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) { 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) luaCmds := util.MustDoString(s.runtime, "local commander = require 'commander'; return commander.registry()").AsTable() 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 { stdin := sink.NewSinkInput(s.runtime, hc.Stdin) diff --git a/nature/runner.lua b/nature/runner.lua index 3d2bb61..9ece224 100644 --- a/nature/runner.lua +++ b/nature/runner.lua @@ -83,6 +83,11 @@ function hilbish.runner.getCurrent() return currentRunner end +local snaili = snail.new() +function hilbish.runner.sh(input) + return snaili:run(input) +end + hilbish.runner.add('hybrid', function(input) local cmdStr = hilbish.aliases.resolve(input) @@ -109,5 +114,5 @@ hilbish.runner.add('lua', function(input) return hilbish.runner.lua(cmdStr) end) -hilbish.runner.add('sh', snail.new()) - +hilbish.runner.add('sh', hilbish.runner.sh) +hilbish.runner.setCurrent 'hybrid'