-
Notifications
You must be signed in to change notification settings - Fork 998
Include any non default hook information in CompositeCommand #5921
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
Conversation
This would be a first step towards addressing wp-cli#5838 and including details on when a specific command is run in the handbook documentation. I've added the output to the help command as well so there will be parody between that and the handbook.
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
* @return string|null | ||
*/ | ||
|
||
function get_hook_description( $hook ) { |
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.
Can this just be a private method on the Help_Command
class?
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.
I believe this needs to be a public util function because the handbook project doesn't use the output of wp help
and needs similar code added there as well in order to have consistency. Was going to do a PR for that one next after this is added.
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.
Can we include some tests too? (Just some basic smoke test for it)
This string can wrap depending on settings, so hardcode various column numbers for consistency.
@danielbachhuber tests added thanks! |
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
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.
Thanks, @mrsdizzie ! I made a few small tweaks you might like to look through ^
@danielbachhuber looks great, thanks much! |
When a command specifies a non-default hook, include those details in handbook documentation for the command. Related: wp-cli/wp-cli#5921 Fixes: wp-cli/wp-cli#5838
When a command specifies a non-default hook, include those details in handbook documentation for the command. Related: wp-cli/wp-cli#5921 Fixes: wp-cli/wp-cli#5838
This would be a first step towards addressing #5838 and including details on when a specific command is run in the handbook documentation.
I've added the output to the help command as well so there will be parity between that and the handbook.
If the parent command defines a
@when
tag, that is passed down to all subcommands. If a subcommand has its own@when
tag, it will take the place of the parent tag. If there is no@when
tag defined for a parent or subcommand, it won't show any hook information with the existing assumption that everything runs on the default hook unless otherwise specified.So now a command like
wp help db reset
would output:Where the
after_wp_config_load
hook is inherited from the parent db command.And
wp help db size
would show:Since it defines a different hook to run on.