Description:
When implementing your own Drush commands, if you get the hook name wrong, drush_invoke stays silent, even if no hooks at all for the command are found.
So for example, if you implement a command called "deploy site" in a command file deploy.drush.inc and use the wrong function name for the command hook, even with --debug and --verbose on, the only information that is output is:
Found command: deploy site [0.556 sec] [bootstrap]
This lack of information is quite confusing for a developer starting out with Drush, given that hook naming system is so flexible (which is great btw).
Suggested Enhancement:
If a command is found but no hooks are found for that command, a log message of level 'error' is output with information such as:
Could not find a hook for command "deploy site".
You may implement any of the following functions:
- drush_deploy_deploy_site()
- drush_deploy_deploy_site_validate()
- drush_deploy_pre_deploy_site()
- drush_deploy_post_deploy_site()
- etc etc etc
This would certainly help new drush developers - I ended up debugging around in drush_invoke in order to find out what drush was actually looking for.
If you think this is a worthwhile addition, I'm happy to submit a patch. I'm checking here first to find out if it's worthwhile.
Comments
Comment #1
moshe weitzman commentedI think it is worthwhile. Might be better as a warning and not an error.
Comment #2
moshe weitzman commentedgreg is now a dispatch expert. assigning to him.
Comment #3
greg.1.anderson commentedGood call.
The code looks something like this:
n.b. The available hook function list switches from a debug message to a warning when no hook functions are found.
However, to avoid problems with source merging, I'm going to put the patch in with #625920: Commands with explicit callback functions skip drush_invoke() API instead.
Comment #4
moshe weitzman commentedgot fixed with #625920: Commands with explicit callback functions skip drush_invoke() API. You now see 2 warnings. The second one is very long and very helpful (i misnamed the example callback to generate this output).