class drush_outputformat_table

  1. 8.0.x commands/core/outputformat/table.inc drush_outputformat_table
  2. 6.x commands/core/outputformat/table.inc drush_outputformat_table
  3. 7.x commands/core/outputformat/table.inc drush_outputformat_table
  4. master commands/core/outputformat/table.inc drush_outputformat_table

Output formatter 'table'

Hierarchy

Expanded class hierarchy of drush_outputformat_table

Members

File

commands/core/outputformat/table.inc, line 33

View source
class drush_outputformat_table extends drush_outputformat {
  function format($input, $metadata) {
    $field_list = isset($metadata['field-labels']) ? $metadata['field-labels'] : array();
    $widths = array();
    $col = 0;
    foreach ($field_list as $key => $label) {
      if (isset($metadata['column-widths'][$key])) {
        $widths[$col] = $metadata['column-widths'][$key];
      }
      ++$col;
    }
    $rows = drush_rows_of_key_value_to_array_table($input, $field_list, $metadata);
    $field_labels = array_key_exists('include-field-labels', $metadata) && $metadata['include-field-labels'];
    if (!$field_labels) {
      array_shift($rows);
    }
    return drush_format_table($rows, $field_labels, $widths);
  }
}