refactor: use hlalias for add function in hilbish.alias interface

lua5.4
TorchedSammy 2022-04-02 10:49:13 -04:00
parent 75b51075b8
commit 37cfae3423
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 1 additions and 19 deletions

View File

@ -69,7 +69,7 @@ func (a *aliasHandler) Resolve(cmdstr string) string {
func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
// create a lua module with our functions
hshaliasesLua := map[string]util.LuaExport{
"add": util.LuaExport{a.luaAdd, 2, false},
"add": util.LuaExport{hlalias, 2, false},
"list": util.LuaExport{a.luaList, 0, false},
"del": util.LuaExport{a.luaDelete, 1, false},
}
@ -80,24 +80,6 @@ func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
return mod
}
func (a *aliasHandler) luaAdd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.CheckNArgs(2); err != nil {
return nil, err
}
alias, err := c.StringArg(0)
if err != nil {
return nil, err
}
cmd, err := c.StringArg(1)
if err != nil {
return nil, err
}
a.Add(alias, cmd)
return c.Next(), nil
}
func (a *aliasHandler) luaList(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
aliasesList := rt.NewTable()
for k, v := range a.All() {