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

pull/16/head
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
1 changed files with 3 additions and 0 deletions

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)
}
}