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

Invoke drush api calls.

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

Call the correct hook for all the modules that implement it. Additionally, the ability to rollback when an error has been encountered is also provided. If at any point during execution, the drush_get_error() function returns anything but 0, drush_invoke() will trigger $hook_rollback for each of the hooks that implement it, in reverse order from how they were executed. Rollbacks are also triggered any time a hook function returns FALSE.

This function will also trigger pre_$hook and post_$hook variants of the hook and its rollbacks automatically.

HOW DRUSH HOOK FUNCTIONS ARE NAMED:

The name of the hook is composed from the name of the command and the name of the command file that the command definition is declared in. The general form for the hook filename is:

drush_COMMANDFILE_COMMANDNAME

In many cases, drush commands that are functionally part of a common collection of similar commands will all be declared in the same file, and every command defined in that file will start with the same command prefix. For example, the command file "pm.drush.inc" defines commands such as "pm-enable" and "pm-disable". In the case of "pm-enable", the command file is "pm", and and command name is "pm-enable". When the command name starts with the same sequence of characters as the command file, then the repeated sequence is dropped; thus, the command hook for "pm-enable" is "drush_pm_enable", not "drush_pm_pm_enable".

Parameters

command: The drush command to execute.

Return value

A boolean specifying whether or not the command was successfully completed.

Related topics

3 calls to drush_invoke()
drush_core_self_update in commands/core/core.drush.inc
drush_drupal_cache_clear_all in includes/drush.inc
drush_upgrade_site_upgrade in commands/core/upgrade.drush.inc
Main command hook for site-upgrade.
1 string reference to 'drush_invoke'
drush_pm_update in commands/pm/pm.drush.inc
Command callback. Execute pm-update.

File

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

Code

function drush_invoke($command) {
  $args = func_get_args();
  array_shift($args);

  return drush_invoke_args($command, $args);
}