drush.api.php

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.

See also

includes/command.inc

See also

hook_drush_init()

@see drush_COMMAND_init()

See also

drush_hook_COMMAND_validate()

@see drush_hook_pre_COMMAND()

See also

drush_hook_COMMAND()

@see drush_hook_post_COMMAND()

See also

drush_hook_post_COMMAND_rollback()

@see drush_hook_COMMAND_rollback()

See also

drush_hook_pre_COMMAND_rollback()

@see drush_hook_COMMAND_validate_rollback()

See also

hook_drush_exit()

Functions

NameDescription
drush_COMMAND_initInitialize 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_COMMANDImplementation of the actual drush command.
drush_hook_COMMAND_validateRun before a specific command executes.
drush_hook_post_COMMANDRun after a specific command executes. Logging an error stops command execution.
drush_hook_pre_COMMANDRun before a specific command executes. Logging an error stops command execution.
drush_hook_pre_sql_syncPost-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_exitTake action after any command is run.
hook_drush_help_alterAdd help components to a command
hook_drush_initTake action before any command is run. Logging an error stops command execution.
hook_drush_pm_adjust_download_destinationAdjust the location that a project should be downloaded to.
hook_drush_pm_post_downloadTake action after a project has been downloaded.
hook_pm_post_updateTake action after a project has been updated.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options