mirror of https://github.com/Hilbis/Hilbish
feat: lua code can now be aliased
parent
83591f9bba
commit
ad14b98b1f
20
shell.go
20
shell.go
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue