function drush_dispatch

8.0.x drush_dispatch($command, $arguments = array())
6.x drush_dispatch($command, $arguments = array())
7.x drush_dispatch($command, $arguments = array())
3.x drush_dispatch($command = NULL)
4.x drush_dispatch($command, $arguments = array())
5.x drush_dispatch($command, $arguments = array())
master 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.


command: A full $command such as returned by drush_get_commands().

arguments: An array of argument values.

See also


Related topics

3 calls to drush_dispatch()
drush_image_flush in commands/core/
drush_main in ./drush.php
The main Drush function.
drush_topic_core_topic in commands/core/
A command callback.


includes/, line 213
The drush command engine.


function drush_dispatch($command, $arguments = array()) {
  $return = FALSE;

  // Set warning for Windows users. We have already loaded site-specific drushrc.

  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

    // Print a warning if someone tries to use a deprecated alias.
    if (isset($command['deprecated'])) {
      drush_log(dt('Warning: The command name "!deprecated" is deprecated.  Please use a recommended form instead (!recommended).', array('!deprecated' => $command['deprecated-name'], '!recommended' => implode(',', array_merge(array($command['command']), $command['aliases'])))), 'warning');
    // 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;