function drush_dispatch
| 6.x command.inc | drush_dispatch($command, $arguments = array()) |
| 5.x command.inc | drush_dispatch($command, |
| 3.x drush.inc | drush_dispatch($command = NULL) |
| 4.x command.inc | drush_dispatch($command, $arguments = array()) |
Given a command record, dispatch it as if it were the original command. Executes in the currently bootstrapped site using the current option contexts. Note that drush_dispatch will not bootstrap any further than the current command has already bootstrapped; therefore, you should only invoke commands that have the same (or lower) bootstrap requirements.
Parameters
command: A full $command such as returned by drush_get_commands(), or a string containing the name of the command record from drush_get_commands() to call.
arguments: An array of argument values.
See also
drush_topic_docs_topic().
Related topics
3 calls to drush_dispatch()
- drush_invoke in includes/
command.inc - Invokes a Drush API call, including all hooks.
- drush_topic_core_topic in commands/
core/ topic.drush.inc - A command callback.
- _drush_bootstrap_and_dispatch in ./
drush.php
File
- includes/
command.inc, line 148 - The drush command engine.
Code
function drush_dispatch($command, $arguments = array()) {
drush_set_command($command);
$return = FALSE;
if ($command) {
// Add arguments, if this has not already been done.
// (If the command was fetched from drush_parse_command,
// then you cannot provide arguments to drush_dispatch.)
if (empty($command['arguments'])) {
_drush_prepare_command($command, $arguments);
}
// Add command-specific options, if applicable.
drush_command_default_options($command);
// Test to see if any of the options in the 'cli' context
// are not represented in the command structure.
if ((_drush_verify_cli_options($command) === FALSE) || (_drush_verify_cli_arguments($command) === FALSE)) {
return FALSE;
}
// Include and validate command engines.
if (_drush_load_command_engines($command) === FALSE) {
return FALSE;
}
// Call the callback function of the active command.
$return = call_user_func_array($command['callback'], $command['arguments']);
}
// Add a final log entry, just so a timestamp appears.
drush_log(dt('Command dispatch complete'), 'notice');
return $return;
}