2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-02 19:53:23 +00:00

feat: Add command.exit signal to bait (#15)

This commit is contained in:
Jack 2021-04-03 14:33:38 -04:00 committed by GitHub
parent 71504c9990
commit ad1be6b5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ func RunInput(input string) {
// If it succeeds, add to history and prompt again
readline.AddHistory(input)
readline.SaveHistory(homedir + "/.hilbish-history")
bait.Em.Emit("command.exit", nil)
bait.Em.Emit("command.success", nil)
return
}
@ -79,12 +80,14 @@ func RunInput(input string) {
} else {
if code, ok := interp.IsExitStatus(err); ok {
if code > 0 {
bait.Em.Emit("command.exit", nil)
bait.Em.Emit("command.fail", code)
}
}
fmt.Fprintln(os.Stderr, err)
}
} else {
bait.Em.Emit("command.exit", nil)
bait.Em.Emit("command.success", nil)
}
}