Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

drush_callback_help

Definition

drush_callback_help()
contributions/drush/drush.module, line 83

Description

Command callback. Display help.

Code

<?php
function drush_callback_help() {
  $commands = func_get_args();

  // Display general help text if no command is specified.
  if (empty($commands)) {
    drush_print(t('Usage: drush.php [options] <command> <command> ...'));
    drush_print();
    drush_print(t('Options: '));
    foreach (drush_get_options() as $option => $description) {
      $rows[] = array($option, $description);
    }

    drush_print_table($rows, 2);
    drush_print();
    drush_print('Commands: ');

    $commands = drush_get_commands();
    $rows = array();
    foreach($commands as $key => $command) {
      $rows[] = array($key, $commands[$key]['description']);
    }
    drush_print_table($rows, 2);
  }
  // Print command specific help.
  else {
    $commandstring = implode(" ", $commands);

    if (!drush_is_command($commandstring)) {
      return drush_error(t('Invalid command !command.', array('!command' => implode(" ", $commands))));
    }

    $help = module_invoke_all('help', 'drush:'. $commandstring);
    if (!empty($help)) {
      drush_print(implode("\n", $help));
    }
    else {
      drush_print(t("No help available for command 'drush $commandstring'."));
    }
  }
}
?>