| 1 |
<?php
|
| 2 |
// $Id: drush.api.php,v 1.2 2009/08/25 19:05:27 weitzman Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Documentation of the Drush API.
|
| 7 |
*
|
| 8 |
* All drush commands are invoked in a specific order, using
|
| 9 |
* drush-made hooks, very similar to the Drupal hook system. See drush_invoke()
|
| 10 |
* for the actual implementation.
|
| 11 |
*
|
| 12 |
* For any command named "hook", the following hooks are called, in
|
| 13 |
* order:
|
| 14 |
*
|
| 15 |
* 1. drush_hook_COMMAND_validate()
|
| 16 |
* 2. drush_hook_pre_COMMAND()
|
| 17 |
* 3. drush_hook_COMMAND()
|
| 18 |
* 4. drush_hook_post_COMMAND()
|
| 19 |
*
|
| 20 |
* For example, here are the hook opportunities for a mysite.drush.inc file
|
| 21 |
* that wants to hook into the `dl` command.
|
| 22 |
*
|
| 23 |
* 1. drush_mysite_dl_validate()
|
| 24 |
* 2. drush_mysite_pre_dl()
|
| 25 |
* 3. drush_mysite_dl()
|
| 26 |
* 4. drush_mysite_post_dl()
|
| 27 |
*
|
| 28 |
* If any of those fails, the rollback mechanism is called. It will
|
| 29 |
* call, in reverse, all _rollback hooks. The mysite command file can implement
|
| 30 |
* the following rollback hooks:
|
| 31 |
*
|
| 32 |
* 1. drush_mysite_post_dl_rollback()
|
| 33 |
* 2. drush_mysite_dl_rollback()
|
| 34 |
* 3. drush_mysite_pre_dl_rollback()
|
| 35 |
* 4. drush_mysite_dl_validate_rollback()
|
| 36 |
*
|
| 37 |
* Before any command is called, drush_hook_init() is also called.
|
| 38 |
*
|
| 39 |
* @see includes/command.inc
|
| 40 |
*
|
| 41 |
* @see drush_hook_init()
|
| 42 |
* @see drush_hook_COMMAND_validate()
|
| 43 |
* @see drush_hook_pre_COMMAND()
|
| 44 |
* @see drush_hook_COMMAND()
|
| 45 |
* @see drush_hook_post_COMMAND()
|
| 46 |
* @see drush_hook_post_COMMAND_rollback()
|
| 47 |
* @see drush_hook_COMMAND_rollback()
|
| 48 |
* @see drush_hook_pre_COMMAND_rollback()
|
| 49 |
* @see drush_hook_COMMAND_validate_rollback()
|
| 50 |
*/
|
| 51 |
|
| 52 |
/**
|
| 53 |
* @addtogroup hooks
|
| 54 |
* @{
|
| 55 |
*/
|
| 56 |
|
| 57 |
/**
|
| 58 |
* Take action before any command is run. Logging an error stops command execution.
|
| 59 |
*/
|
| 60 |
function drush_hook_init() {
|
| 61 |
|
| 62 |
}
|
| 63 |
|
| 64 |
/**
|
| 65 |
* Run before a specific command executes.
|
| 66 |
*
|
| 67 |
* Logging an error stops command execution, and the rollback function (if any)
|
| 68 |
* for each hook implementation is invoked.
|
| 69 |
*
|
| 70 |
* @see drush_hook_COMMAND_validate_rollback()
|
| 71 |
*/
|
| 72 |
function drush_hook_COMMAND_validate() {
|
| 73 |
|
| 74 |
}
|
| 75 |
|
| 76 |
/**
|
| 77 |
* Run before a specific command executes. Logging an error stops command execution.
|
| 78 |
*
|
| 79 |
* Logging an error stops command execution, and the rollback function (if any)
|
| 80 |
* for each hook implementation is invoked, in addition to the
|
| 81 |
* validate rollback.
|
| 82 |
*
|
| 83 |
* @see drush_hook_pre_COMMAND_rollback()
|
| 84 |
* @see drush_hook_COMMAND_validate_rollback()
|
| 85 |
*/
|
| 86 |
function drush_hook_pre_COMMAND() {
|
| 87 |
|
| 88 |
}
|
| 89 |
|
| 90 |
/**
|
| 91 |
* Implementation of the actual drush command.
|
| 92 |
*
|
| 93 |
* This is where most of the stuff should happen.
|
| 94 |
*
|
| 95 |
* Logging an error stops command execution, and the rollback function (if any)
|
| 96 |
* for each hook implementation is invoked, in addition to pre and
|
| 97 |
* validate rollbacks.
|
| 98 |
*
|
| 99 |
* @see drush_hook_COMMAND_rollback()
|
| 100 |
* @see drush_hook_pre_COMMAND_rollback()
|
| 101 |
* @see drush_hook_COMMAND_validate_rollback()
|
| 102 |
*/
|
| 103 |
function drush_hook_COMMAND() {
|
| 104 |
|
| 105 |
}
|
| 106 |
|
| 107 |
/**
|
| 108 |
* Run after a specific command executes. Logging an error stops command execution.
|
| 109 |
*
|
| 110 |
* Logging an error stops command execution, and the rollback function (if any)
|
| 111 |
* for each hook implementation is invoked, in addition to pre, normal
|
| 112 |
* and validate rollbacks.
|
| 113 |
*
|
| 114 |
* @see drush_hook_post_COMMAND_rollback()
|
| 115 |
* @see drush_hook_COMMAND_rollback()
|
| 116 |
* @see drush_hook_pre_COMMAND_rollback()
|
| 117 |
* @see drush_hook_COMMAND_validate_rollback()
|
| 118 |
*/
|
| 119 |
function drush_hook_post_COMMAND() {
|
| 120 |
|
| 121 |
}
|
| 122 |
|
| 123 |
/**
|
| 124 |
* Take action after any command is run.
|
| 125 |
*/
|
| 126 |
function hook_drush_exit() {
|
| 127 |
|
| 128 |
}
|
| 129 |
|
| 130 |
/**
|
| 131 |
* Take action after a project has been downloaded.
|
| 132 |
*/
|
| 133 |
function hook_drush_pm_post_install($project, $release, $destination) {
|
| 134 |
|
| 135 |
}
|
| 136 |
|
| 137 |
/**
|
| 138 |
* Take action after a project has been updated.
|
| 139 |
*/
|
| 140 |
function hook_pm_post_update($release_name, $release_candidate_version, $project_parent_path) {
|
| 141 |
|
| 142 |
}
|
| 143 |
|
| 144 |
/**
|
| 145 |
* @} End of "addtogroup hooks".
|
| 146 |
*/
|