function drush_outputformat_table::format

8.0.x table.inc drush_outputformat_table::format($input, $metadata)
6.x table.inc drush_outputformat_table::format($input, $metadata)
7.x table.inc drush_outputformat_table::format($input, $metadata)
master table.inc drush_outputformat_table::format($input, $metadata)

Overrides drush_outputformat::format

File

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

Class

drush_outputformat_table
Output formatter 'table'

Code

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);
}