function outputformat_drush_help_alter

8.0.x outputformat.drush.inc outputformat_drush_help_alter(&$command)
6.x outputformat.drush.inc outputformat_drush_help_alter(&$command)
7.x outputformat.drush.inc outputformat_drush_help_alter(&$command)
master outputformat.drush.inc outputformat_drush_help_alter(&$command)

Implements hook_drush_help_alter().

File

commands/core/outputformat.drush.inc, line 260
Core drush output formats.

Code

function outputformat_drush_help_alter(&$command) {
  if (isset($command['engines']['outputformat'])) {
    $outputformat = $command['engines']['outputformat'];
    // If the command defines specific field labels,
    // then modify the help for --fields to include
    // specific information about the available fields.
    if (isset($outputformat['field-labels'])) {
      $all_fields = array();
      $all_fields_description = array();
      foreach ($outputformat['field-labels'] as $field => $human_readable) {
        $all_fields[] = $field;
        if ((strtolower($field) != strtolower($human_readable)) && !array_key_exists(strtolower($human_readable), $outputformat['field-labels'])) {
          $all_fields_description[] = $field . dt(" (or '!other')", array('!other' => strtolower($human_readable)));
        }
        else {
          $all_fields_description[] = $field;
        }
      }
      $field_defaults = isset($outputformat['fields-default']) ? $outputformat['fields-default'] : $all_fields;
      $command['options']['fields']['example-value'] = implode(', ', $field_defaults);
      $command['options']['fields']['description'] .= ' ' . dt('All available fields are: !fields.', array('!fields' => implode(', ', $all_fields_description)));
      if (isset($outputformat['fields-default'])) {
        $command['options']['full']['description'] = dt("Show the full output, with all fields included.");
      }
    }
    else {
      // If the command does not define specific field labels,
      // then hide the help for --fields unless the command
      // uses output format engines that format tables.
      if (isset($outputformat['require-engine-capability']) && is_array($outputformat['require-engine-capability'])) {
        if (!in_array('format-table', $outputformat['require-engine-capability'])) {
          unset($command['options']['fields']);
          unset($command['options']['field-labels']);
        }
      }
      // If the command does define output formats, but does not
      // define fields, then just hide the help for the --fields option.
      else {
        $command['options']['fields']['hidden'] = TRUE;
        $command['options']['field-labels']['hidden'] = TRUE;
      }
    }

    // If the command defines a default pipe format, then
    // add '--pipe   Equivalent to --format=<pipe-default>'.
    if (isset($outputformat['pipe-format'])) {
      if (isset($command['options']['pipe'])) {
        $command['options']['pipe'] .= ' ';
      }
      else {
        $command['options']['pipe'] = '';
      }
      if (isset($outputformat['pipe-metadata']['message-template'])) {
        $command['options']['pipe'] .= dt('Displays output in the form "!message"', array('!message' => $outputformat['pipe-metadata']['message-template']));
      }
      else {
        $command['options']['pipe'] .= dt("Equivalent to --format=!default.", array('!default' => $outputformat['pipe-format']));
      }
    }
  }
}