function drush_get_commands

8.0.x drush_get_commands($reset = FALSE)
6.x drush_get_commands()
7.x drush_get_commands($reset = FALSE)
3.x drush_get_commands()
4.x drush_get_commands()
5.x drush_get_commands()
master 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.

18 calls to drush_get_commands()
commandUnitCase::testGetCommands in tests/commandUnitTest.php
core_help_complete in commands/core/
Command argument complete callback.
drush_command_belongs_to_disabled_module in ./drush.php
Check if the given command belongs to a disabled module
drush_complete_rebuild in includes/
Rebuild and cache completions for everything except command arguments.
drush_complete_rebuild_arguments in includes/
Rebuild and cache completions for command arguments.

... See full list


includes/, line 977
The drush command engine.


function drush_get_commands() {
  $commands = $available_commands = array();
  $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.

        // Translate command.

        // If command callback function name begins with "drush_$commandfile_",
        // then fix up the command entry so that drush_invoke will be
        // called by way of drush_command.  This will cause all
        // of the applicable hook functions to be called for the
        // command when it is invoked.  If the callback function does
        // -not- begin with its commandfile name, then it will be
        // called directly by drush_dispatch, and no hook functions
        // will be called (e.g. you cannot hook drush_print_file).
        if ($command['callback'] != 'drush_command') {
          $required_command_prefix = 'drush_' . $commandfile . '_';
          if ((substr($command['callback'], 0, strlen($required_command_prefix)) == $required_command_prefix)) {
            $command['command-hook'] = substr($command['callback'], strlen('drush_'));
            $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 drush_set_context('DRUSH_COMMANDS', $commands);