function drush_invoke

8.0.x command.inc drush_invoke($command, $arguments = array())
6.x command.inc drush_invoke($command, $arguments = array())
7.x command.inc drush_invoke($command, $arguments = array())
3.x command.inc drush_invoke($command)
4.x command.inc drush_invoke($command)
5.x command.inc drush_invoke($command, $arguments = array())
master command.inc drush_invoke($command, $arguments = array())

Invokes a Drush API call, including all hooks.

Executes the specified command with the specified arguments on the currently bootstrapped site using the current option contexts. Note that it 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.

Commands execute with the same options that the user provided on the commandline. If you need to invoke another Drush command with options you specify, use drush_invoke_process() instead.

Parameters

string $command: The command to invoke.

array $arguments: An array of argument to pass into the command.

Return value

mixed|false The return value from drush_dispatch() or FALSE on error.

See also

drush_invoke_process()

Related topics

4 calls to drush_invoke()
drush_core_quick_drupal in commands/core/core.drush.inc
Callback for core-quick-drupal command.
drush_make in commands/make/make.drush.inc
Drush callback; make based on the makefile.
drush_pm_update in commands/pm/pm.drush.inc
Command callback. Execute pm-update.
drush_pm_updatecode in commands/pm/updatecode.pm.inc
Command callback. Displays update status info and allows to update installed projects.

File

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

Code

function drush_invoke($command, $arguments = array()) {
  // Convert a standalone argument to a single-element array.
  if (!is_array($arguments)) {
    $arguments = array($arguments);
  }
  $commands = drush_get_commands();
  if (array_key_exists($command, $commands)) {
    $command = $commands[$command];
    // Drush overloads the 'arguments' element, which contains the help string
    // for the allowed arguments for the command when fetched, and is fixed up
    // by _drush_prepare_command() to contain the actual commandline arguments
    // during dispatching.
    $command['arguments'] = array();
    return drush_dispatch($command, $arguments);
  }
  else {
    return drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!command' could not be found.", array('!command' => $command)));
  }
}