function drush_dispatch

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

arguments: An array of argument values.

See also

drush_topic_docs_topic().

Related topics

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

File

includes/command.inc, line 213
The drush command engine.

Code

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

  // Set warning for Windows users. We have already loaded site-specific drushrc.
  drush_environment_check_os();

  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);

    // 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;
}