mirror of https://github.com/Hilbis/Hilbish
refactor: use hlalias for add function in hilbish.alias interface
parent
75b51075b8
commit
37cfae3423
20
aliases.go
20
aliases.go
|
@ -69,7 +69,7 @@ func (a *aliasHandler) Resolve(cmdstr string) string {
|
||||||
func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
|
func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
|
||||||
// create a lua module with our functions
|
// create a lua module with our functions
|
||||||
hshaliasesLua := map[string]util.LuaExport{
|
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},
|
"list": util.LuaExport{a.luaList, 0, false},
|
||||||
"del": util.LuaExport{a.luaDelete, 1, false},
|
"del": util.LuaExport{a.luaDelete, 1, false},
|
||||||
}
|
}
|
||||||
|
@ -80,24 +80,6 @@ func (a *aliasHandler) Loader(rtm *rt.Runtime) *rt.Table {
|
||||||
return mod
|
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) {
|
func (a *aliasHandler) luaList(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
aliasesList := rt.NewTable()
|
aliasesList := rt.NewTable()
|
||||||
for k, v := range a.All() {
|
for k, v := range a.All() {
|
||||||
|
|
Loading…
Reference in New Issue