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.

11 calls to drush_get_commands()
core_cli_bashrc in commands/core/core.drush.inc
drush_core_help in commands/core/help.drush.inc
Command callback for help command. This is the default command, when none other has been specified.
drush_docs_errorcodes in commands/core/docs.drush.inc
docs-error-codes command. Print a list of all error codes that can be found.
drush_get_commandfile_for_command in includes/command.inc
Get the short commandfile name that matches the command.
drush_get_topics in commands/core/topic.drush.inc
Retrieve all defined topics

... See full list

File

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

Code

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);
        // Translate command.
        drush_command_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;
          }
        }
        // Do the same operation on the deprecated aliases.
        if (isset($command['deprecated-aliases']) && count($command['deprecated-aliases'])) {
          foreach ($command['deprecated-aliases'] as $alias) {
            $commands[$alias] = $command;
            $commands[$alias]['is_alias'] = TRUE;
            $commands[$alias]['deprecated'] = TRUE;
            $commands[$alias]['deprecated-name'] = $alias;
          }
        }

      }
    }
  }

  return drush_set_context('DRUSH_COMMANDS', $commands);
}