function drush_parse_command

8.0.x drush_parse_command()
6.x drush_parse_command()
7.x drush_parse_command()
3.x drush_parse_command()
4.x drush_parse_command()
5.x drush_parse_command()
master drush_parse_command()

Matches a commands array, as returned by drush_get_arguments, with the current command table.

Note that not all commands may be discoverable at the point-of-call, since Drupal modules can ship commands as well, and they are not available until after bootstrapping.

drush_parse_command returns a normalized command descriptor, which is an associative array. Some of its entries are:

  • callback arguments: an array of arguments to pass to the calback.
  • description: description of the command.
  • arguments: an array of arguments that are understood by the command. for help texts.
  • options: an array of options that are understood by the command. for help texts.
  • examples: an array of examples that are understood by the command. for help texts.
  • scope: one of 'system', 'project', 'site'.
  • bootstrap: drupal bootstrap level (depends on Drupal major version). -1=no_bootstrap.
  • core: Drupal major version required.
  • drupal dependencies: drupal modules required for this command.
  • drush dependencies: other drush command files required for this command.
2 calls to drush_parse_command()
drush_main in ./drush.php
The main Drush function.
drush_redispatch_get_options in includes/
Get the options that were passed to the current command.


includes/, line 774
The drush command engine.


function drush_parse_command() {
  $args = drush_get_arguments();
  $command = FALSE;

  // Get a list of all implemented commands.
  $implemented = drush_get_commands();
  if (isset($implemented[$args[0]])) {
    $command = $implemented[$args[0]];
    $arguments = array_slice($args, 1);

  // We have found a command that matches. Set the appropriate values.
  if ($command) {
    // Special case. Force help command if --help option was specified.
    if (drush_get_option(array('h', 'help'))) {
      $arguments = array($command['command']);
      $command = $implemented['help'];
      $command['arguments'] = $arguments;
    else {
      _drush_prepare_command($command, $arguments);
  return $command;