feat: lua code can now be aliased

pull/59/head
sammyette 2021-05-16 08:43:19 -04:00
parent 83591f9bba
commit ad14b98b1f
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 10 additions and 10 deletions

View File

@ -14,8 +14,17 @@ import (
)
func RunInput(input string) {
cmdArgs, cmdString := splitInput(input)
// If alias was found, use command alias
if aliases[cmdArgs[0]] != "" {
alias := aliases[cmdArgs[0]]
cmdString = alias + strings.Trim(cmdString, cmdArgs[0])
cmdArgs, cmdString = splitInput(cmdString)
}
// First try to load input, essentially compiling to bytecode
fn, err := l.LoadString(input)
fn, err := l.LoadString(cmdString)
if err != nil && noexecute {
fmt.Println(err)
return
@ -33,15 +42,6 @@ func RunInput(input string) {
return
}
cmdArgs, cmdString := splitInput(input)
// If alias was found, use command alias
if aliases[cmdArgs[0]] != "" {
alias := aliases[cmdArgs[0]]
cmdString = alias + strings.Trim(cmdString, cmdArgs[0])
cmdArgs, cmdString = splitInput(cmdString)
}
// If command is defined in Lua then run it
if commands[cmdArgs[0]] {
err := l.CallByParam(lua.P{