function drush_command

8.0.x command.inc drush_command()
6.x command.inc drush_command()
7.x command.inc drush_command()
3.x command.inc drush_command()
4.x command.inc drush_command()
5.x command.inc drush_command()
master command.inc drush_command()

Entry point for commands into the drush_invoke API

If a command does not have a callback specified, this function will be called.

This function will trigger $hook_drush_init, then if no errors occur, it will call drush_invoke() with the command that was dispatch.

If no errors have occured, it will run $hook_drush_exit.

1 string reference to 'drush_command'
drush_get_commands in includes/command.inc
Get a list of all implemented commands. This invokes hook_drush_command().

File

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

Code

function drush_command() {
  $args = func_get_args();
  $command = drush_get_command();

  foreach (drush_command_implements("drush_init") as $name) {
    $func = $name . '_drush_init';
    drush_log(dt("Initializing drush commandfile: !name", array('!name' => $name)), 'bootstrap');
    call_user_func_array($func, $args);
    _drush_log_drupal_messages();
  }

  if (!drush_get_error()) {
    call_user_func_array('drush_invoke', array_merge(array($command['command-hook']), $args));
  }

  if (!drush_get_error()) {
    foreach (drush_command_implements('drush_exit') as $name) {
      $func = $name . '_drush_exit';
      call_user_func_array($func, $args);
      _drush_log_drupal_messages();
    }
  }
}