The 'table' formatter will convert an associative array into a formatted, word-wrapped table. Each item in the associative array represents one row in the table. Each row is similarly composed of associative arrays, with the key of each item indicating the column, and the value indicating the contents of the cell. See below for an example source array.
The command core-requirements is an example of a command that produces output in a tabular format.
$ drush core-requirements
Title Severity Description Cron maintenance Error Last run 2 weeks ago tasks Cron has not run recently. For more information, see the online handbook entry for configuring cron jobs. You can run cron manually. Drupal Info 7.19(Note: the output above has been shortened for clarity; the actual output of core-requirements contains additional rows not shown here.)
It is possible to determine the available fields by consulting drush help core requirements:
--fields=<title, severity, description> Fields to output. All available fields are: title, severity, sid, description, value, reason, weight.It is possible to control the fields that appear in the table, and their order, by naming the desired fields in the --fields option. The space between items is optional, so `--fields=title,sid` is valid.
Code:
return array ( 'cron' => array ( 'title' => 'Cron maintenance tasks', 'severity' => 2, 'value' => 'Last run 2 weeks ago', 'description' => 'Cron has not run recently. For more information, see the online handbook entry for configuring cron jobs. You can run cron manually.', 'severity-label' => 'Error', ), 'drupal' => array ( 'title' => 'Drupal', 'value' => '7.19', 'severity' => -1, 'weight' => -10, 'severity-label' => 'Info', ), )