function drush_get_commands

8.0.x command.inc drush_get_commands($reset = FALSE)
6.x command.inc drush_get_commands()
7.x command.inc drush_get_commands($reset = FALSE)
3.x command.inc drush_get_commands()
4.x command.inc drush_get_commands()
5.x command.inc drush_get_commands()
master command.inc drush_get_commands($reset = FALSE)

Get a list of all implemented commands. This invokes hook_drush_command().

Return value

Associative array of currently active command descriptors.

22 calls to drush_get_commands()
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.
core_help_complete in commands/core/help.drush.inc
Command argument complete callback.
DrupalBoot::drush_command_belongs_to_disabled_module in lib/Drush/Boot/DrupalBoot.php
Check if the given command belongs to a disabled module.
drush_bootstrap in includes/bootstrap.inc
Bootstrap Drush to the desired phase.
drush_command_normalize_name in includes/command.inc

... See full list

File

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

Code

function drush_get_commands($reset = FALSE) {
  static $commands = array();

  if ($reset) {
    $commands = array();
    return;
  }
  elseif ($commands) {
    return $commands;
  }

  $list = drush_commandfile_list();
  foreach ($list as $commandfile => $path) {
    if (drush_command_hook($commandfile, 'drush_command')) {
      $function = $commandfile . '_drush_command';
      $result = $function();
      foreach ((array) $result as $key => $command) {
        // Add some defaults and normalize the command descriptor.
        $command += drush_command_defaults($key, $commandfile, $path);

        // Add engine data.
        drush_merge_engine_data($command);

        // Translate command.
        drush_command_translate($command);

        // If the command callback is not 'drush_command', then
        // copy the callback function to an alternate element
        // of the command array that will be called when Drush
        // calls the command function hooks.  Then, set the
        // callback to drush_command so that the function hooks
        // will be called.
        if (($command['callback'] != 'drush_command') && $command['invoke hooks']) {
          $command['primary function'] = $command['callback'];
          $command['callback'] = 'drush_command';
        }

        $commands[$key] = $command;
        // For every alias, make a copy of the command and store it in the command list
        // using the alias as a key
        if (isset($command['aliases']) && count($command['aliases'])) {
          foreach ($command['aliases'] as $alias) {
            $commands[$alias] = $command;
            $commands[$alias]['is_alias'] = TRUE;
          }
        }
      }
    }
  }

  return $commands;
}