-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hooks for life cycle events: using .hook() #1514
Conversation
This comment has been minimized.
This comment has been minimized.
Why not preHandler or afterHandler to also cover executable? The stand-alone executable seems quite different, and I have been avoiding tackling! Initial concerns without deep digging:
|
As noted in #1519 (comment), the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @abetomo I'll take another look at the code refactor next, and then focus on a prerelease of Commander v8. |
Pull Request
Problem
People ask for a way to run code before the action handler with access to the parsed options. And also some requests for a hook after the action.
Main issue: #1197
Related issues: #76 #229 #936 #996 #1158 #1457
Solution
Add
.hook(event, callback)
methodSupported hooks:
preAction
,postAction
. Triggered by action handler for hooked command and its subcommands.Callback is passed the hooked command and the command running the action handler.
ChangeLog
.hook()
with support for"preAction"
and"postAction"
callbacks