function drush_show_help

8.0.x help.drush.inc drush_show_help($commandstring)
6.x help.drush.inc drush_show_help($commandstring)
7.x help.drush.inc drush_show_help($commandstring)
3.x drush.inc drush_show_help($commands)
4.x drush.inc drush_show_help($commandstring)
5.x help.drush.inc drush_show_help($commandstring)

Prints out help for a given command.

2 calls to drush_show_help()
drush_core_help in commands/core/core.drush.inc
This is called if no command or an unknown command is entered.
drush_help_html in commands/core/core.drush.inc
Return an HTML page documenting all available commands and global options.

File

includes/drush.inc, line 658
The drush API implementation and helpers.

Code

function drush_show_help($commands) {
  $phases = _drush_bootstrap_phases();

  $commandstring = implode(" ", $commands);

  foreach ($phases as $phase_index) {
    if ($validated = drush_bootstrap_validate($phase_index)) {
      if ($phase_index > drush_get_context('DRUSH_BOOTSTRAP_PHASE')) {
        drush_bootstrap($phase_index);
      }
    }
    if (!drush_get_error()) {
      $commands = drush_get_commands();
      if (array_key_exists($commandstring, $commands)) {
        $command = $commands[$commandstring];

        if ($validated && $command['bootstrap'] > $phase_index) {
          continue;
        }

        // Merge in engine specific help.
        foreach ($command['engines'] as $type => $description) {
          $all_engines = drush_get_engines($type);
          foreach ($all_engines as $name => $engine) {
            $command = array_merge_recursive($command, $engine);
          }
        }

        if (!$help = drush_command_invoke_all('drush_help', 'drush:' . $command['command'])) {
          $help = array($command['description']);
        }
        drush_print(wordwrap(implode("\n", $help), drush_get_context('DRUSH_COLUMNS', 80)));
        drush_print();

        // TODO: Let commands define additional sections.
        $sections = array(
          'examples' => 'Examples',
          'arguments' => 'Arguments',
          'options' => 'Options',
        );

        foreach ($sections as $key => $value) {
          if (!empty($command[$key])) {
            drush_print(dt($value) . ':');
            foreach ($command[$key] as $name => $description) {
              // '[command] is a token representing the current command. @see pm_drush_engine_version_control().
              $rows[] = array(str_replace('[command]', $commandstring, $name), dt($description));
            }
            drush_print_table($rows, false, array(40));
            unset($rows);
            drush_print();
          }
        }

        // Append aliases if any.
        if ($command['aliases']) {
          drush_print(dt("Aliases: ") . implode(', ', $command['aliases']));
        }

        return TRUE;

      }
    }
    else {
      break;
    }
  }
  return drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt('Invalid command !command.', array('!command' => $commandstring)));
}