2
3
kopie van https://github.com/sammy-ette/Hilbish synced 2025-08-10 02:52:03 +00:00

Vergelijk commits

...

4 Commits

Auteur SHA1 Bericht Datum
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
sammyette
4596159b8f
feat: add command.precmd hook 2021-10-13 22:53:09 -04:00
sammyette
9eabe5323d
fix: throw command.exit with 0 code if input is nothing 2021-10-13 22:51:38 -04:00
4 gewijzigde bestanden met toevoegingen van 7 en 2 verwijderingen

Bestand weergeven

@ -30,6 +30,6 @@ func (b *Bait) throw(name string, args ...interface{}) {
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)
}

Bestand weergeven

@ -184,7 +184,10 @@ input:
}
input = strings.TrimSpace(input)
if len(input) == 0 { continue }
if len(input) == 0 {
hooks.Em.Emit("command.exit", 0)
continue
}
if strings.HasSuffix(input, "\\") {
for {

1
rl.go
Bestand weergeven

@ -22,6 +22,7 @@ func NewLineReader(prompt string) *LineReader {
}
func (lr *LineReader) Read() (string, error) {
hooks.Em.Emit("command.precmd", nil)
return readline.String(lr.Prompt)
}

Bestand weergeven

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