Compare commits

...

2 Commits

Author SHA1 Message Date
sammyette e4833bdba9
feat: add command.preexec hook
it provides 2 arguments: what the user typed, and the command hilbish
will execute.
2021-10-14 08:51:29 -04:00
sammyette 63061e3a52
fix(bait): allow more than 1 argment for catch callback 2021-10-13 23:41:20 -04:00
2 changed files with 2 additions and 1 deletions

View File

@ -30,6 +30,6 @@ func (b *Bait) throw(name string, args ...interface{}) {
b.Em.Emit(name, args...) b.Em.Emit(name, args...)
} }
func (b *Bait) catch(name string, catcher func(interface{})) { func (b *Bait) catch(name string, catcher func(...interface{})) {
b.Em.On(name, catcher) b.Em.On(name, catcher)
} }

View File

@ -31,6 +31,7 @@ func RunInput(input string) {
continue continue
} }
} }
hooks.Em.Emit("command.preexec", input, cmdString)
// First try to load input, essentially compiling to bytecode // First try to load input, essentially compiling to bytecode
fn, err := l.LoadString(cmdString) fn, err := l.LoadString(cmdString)