function drush_invoke

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


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


Related topics

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


includes/, line 37
The drush command engine.


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