function drush_core_help

8.0.x help.drush.inc drush_core_help()
6.x help.drush.inc drush_core_help()
7.x help.drush.inc drush_core_help()
3.x core.drush.inc drush_core_help()
4.x help.drush.inc drush_core_help()
5.x help.drush.inc drush_core_help()
master help.drush.inc drush_core_help($name = '')

Command callback for help command. This is the default command, when none other has been specified.

File

commands/core/help.drush.inc, line 89

Code

function drush_core_help($name = '') {
  $format = drush_get_option('format', 'table');
  if ($name) {
    // helpsingle command builds output when a command is specified.
    $options = drush_redispatch_get_options();
    if ($name != 'help') {
      unset($options['help']);
    }
    $return = drush_invoke_process('@self', 'helpsingle', func_get_args(), $options);
    drush_backend_set_result($return['object']);
    return;
  }

  drush_bootstrap_max();
  drush_get_commands(true);
  $implemented = drush_get_commands();
  ksort($implemented);
  $command_categories = drush_commands_categorize($implemented);
  if ($format != 'table') {
    return $command_categories;
  }
  else {
    $visible = drush_help_visible($command_categories);

    // If the user specified --filter w/out a value, then
    // present a choice list of help categories.
    if (drush_get_option('filter', FALSE) === TRUE) {
      $help_categories = array();
      foreach ($command_categories as $key => $info) {
        $description = $info['title'];
        if (array_key_exists('summary', $info)) {
          $description .= ": " . $info['summary'];
        }
        $help_categories[$key] = $description;
      }
      $result = drush_choice($help_categories, 'Select a help category:');
      if (!$result) {
        return drush_user_abort();
      }
      drush_set_option('filter', $result);
    }
    // Filter out categories that the user does not want to see
    $filter_category = drush_get_option('filter');
    if (!empty($filter_category) && ($filter_category !== TRUE)) {
      if (!array_key_exists($filter_category, $command_categories)) {
        return drush_set_error('DRUSH_NO_CATEGORY', dt("The specified command category !filter does not exist.", array('!filter' => $filter_category)));
      }
      $command_categories = array($filter_category => $command_categories[$filter_category]);
    }

    // Make a fake command section to hold the global options, then print it.
    $global_options_help = drush_global_options_command(TRUE);
    if (!drush_get_option('filter')) {
      drush_print_help($global_options_help);
    }
    drush_help_listing_print($command_categories);
    drush_backend_set_result($command_categories);
    return;
  }
}