-
Notifications
You must be signed in to change notification settings - Fork 8
Handling Events
mosop edited this page Dec 11, 2016
·
4 revisions
A callback is a Proc object to be invoked when an event occur. The callback feature is provided by the Callback library. For more information about the library, see README.
Crystal CLI provides the following events:
- initialize: occurs when a command is initialized.
- exit: occurs when a command ends or exits. A callback receives a Cli::Exit object.
class FinallySmile < Cli::Command
after_exit do |cmd, exit|
cmd.puts exit.message
cmd.puts ":)"
end
def run
exit! ":("
end
end
FinallySmile.runOutput:
:(
:(
:)