Version 1.12 (checked in on 2010-08-18 at 05:38:42 by greg1anderson)
Documentation of the Drush API.
All drush commands are invoked in a specific order, using drush-made hooks, very similar to the Drupal hook system. See drush_invoke() for the actual implementation.
For any commandfile named "hook", the following hooks are called, in order, for the command "COMMAND":
0. drush_COMMAND_init() 1. drush_hook_COMMAND_validate() 2. drush_hook_pre_COMMAND() 3. drush_hook_COMMAND() 4. drush_hook_post_COMMAND()
For example, here are the hook opportunities for a mysite.drush.inc file that wants to hook into the `pm-download` command.
1. drush_mysite_pm_download_validate() 2. drush_mysite_pre_pm_download() 3. drush_mysite_pm_download() 4. drush_mysite_post_pm_download()
Note that the drush_COMMAND_init() hook is only for use by the commandfile that defines the command.
If any of hook function fails, the rollback mechanism is called. It will call, in reverse, all _rollback hooks. The mysite command file can implement the following rollback hooks:
1. drush_mysite_post_pm_download_rollback() 2. drush_mysite_pm_download_rollback() 3. drush_mysite_pre_pm_download_rollback() 4. drush_mysite_pm_download_validate_rollback()
Before any command is called, hook_drush_init() is also called. hook_drush_exit() is called at the very end of command invocation.
includes/command.inc
@see drush_COMMAND_init()
@see drush_hook_pre_COMMAND()
@see drush_hook_post_COMMAND()
drush_hook_post_COMMAND_rollback()
@see drush_hook_COMMAND_rollback()
drush_hook_pre_COMMAND_rollback()
@see drush_hook_COMMAND_validate_rollback()
| Name | Description |
|---|---|
| drush_COMMAND_init | Initialize a command prior to validation. If a command needs to bootstrap to a higher level, this is best done in the command init hook. It is permisible to bootstrap in any hook, but note that if bootstrapping adds more commandfiles (*.drush.inc)... |
| drush_hook_COMMAND | Implementation of the actual drush command. |
| drush_hook_COMMAND_validate | Run before a specific command executes. |
| drush_hook_post_COMMAND | Run after a specific command executes. Logging an error stops command execution. |
| drush_hook_pre_COMMAND | Run before a specific command executes. Logging an error stops command execution. |
| drush_hook_pre_sql_sync | Post-sync sanitization example. This is equivalent to the built-in --sanitize option of sql-sync, but simplified to only work with default values on Drupal 6 + mysql. |
| hook_drush_exit | Take action after any command is run. |
| hook_drush_help_alter | Add help components to a command |
| hook_drush_init | Take action before any command is run. Logging an error stops command execution. |
| hook_drush_pm_adjust_download_destination | Adjust the location that a project should be downloaded to. |
| hook_drush_pm_post_download | Take action after a project has been downloaded. |
| hook_pm_post_update | Take action after a project has been updated. |