feat: add hilbish.aliases.resolve to resolve an alias

insensitive-tab^2
TorchedSammy 10 months ago
parent 3db6334445
commit 984b8a4308
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

@ -72,6 +72,7 @@ func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
"add": util.LuaExport{hlalias, 2, false},
"list": util.LuaExport{a.luaList, 0, false},
"del": util.LuaExport{a.luaDelete, 1, false},
"resolve": util.LuaExport{a.luaResolve, 1, false},
}
mod := rt.NewTable()
@ -101,3 +102,16 @@ func (a *aliasHandler) luaDelete(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.Next(), nil
}
func (a *aliasHandler) luaResolve(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil {
return nil, err
}
alias, err := c.StringArg(0)
if err != nil {
return nil, err
}
resolved := a.Resolve(alias)
return c.PushingNext1(t.Runtime, rt.StringValue(resolved)), nil
}

Loading…
Cancel
Save