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.

Related topics

3 string references to 'drush_command'
commandUnitCase::testGetCommands in tests/commandUnitTest.php
Assert that $command has interesting properties. Reference command by it's alias (dl) to assure that those aliases are built as expected.
drush_command_defaults in includes/command.inc
drush_get_commands in includes/command.inc
Get a list of all implemented commands. This invokes hook_drush_command().

File

includes/command.inc, line 204
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';
    if (drush_get_option('show-invoke')) {
      drush_log(dt("Calling global init hook: !func", array('!name' => $name, '!func' => $func . '()')), LogLevel::BOOTSTRAP);
    }
    call_user_func_array($func, $args);
    _drush_log_drupal_messages();
  }

  if (!drush_get_error()) {
    $result = _drush_invoke_hooks($command, $args);
  }

  if (!drush_get_error()) {
    foreach (drush_command_implements('drush_exit') as $name) {
      $func = $name . '_drush_exit';
      if (drush_get_option('show-invoke')) {
        drush_log(dt("Calling global exit hook: !func", array('!name' => $name, '!func' => $func . '()')), LogLevel::BOOTSTRAP);
      }
      call_user_func_array($func, $args);
      _drush_log_drupal_messages();
    }
  }
}