Include any non default hook information in CompositeCommand#5921
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 <[email protected]>
| * @return string|null | ||
| */ | ||
|
|
||
| function get_hook_description( $hook ) { |
There was a problem hiding this comment.
Can this just be a private method on the Help_Command class?
There was a problem hiding this comment.
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.
danielbachhuber
left a comment
There was a problem hiding this comment.
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! |
danielbachhuber
left a comment
There was a problem hiding this comment.
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
@whentag, that is passed down to all subcommands. If a subcommand has its own@whentag, it will take the place of the parent tag. If there is no@whentag 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 resetwould output:Where the
after_wp_config_loadhook is inherited from the parent db command.And
wp help db sizewould show:Since it defines a different hook to run on.