I'm getting into my first drush command and coming up with a ton of things I don't understand. Basically, I need to output a list of image files referenced in my content, and the best seemed to be to output it in a table format so that the different bits of information would be easy to see and distinguish from each other.
I started by following the tutorial and did this (in the COMMAND_drush_command $items array):
'engines' => array(
'outputformat' => array(
'default' => 'table',
'pipe-format' => 'json',
// Commands that return deep arrays will usually use
// machine-ids for the column data. A 'field-labels'
// item maps from the machine-id to a human-readable label.
'field-labels' => array(
'node' => 'Nid',
'title' => 'Title',
'filename' => 'Filename',
'directory' => 'Directory',
),
// In table format, the 'column-widths' item is consulted
// to determine the default weights for any named column.
'column-widths' => array(
'title' => 20,
),
'require-engine-capability' => array('format-table'),
),
That worked fine, because I built an array of output line by line and at the end of the command passed it back to drush which duly printed it. The only problem is that there is a LOT of data, so the command gives the appearance of hanging. So I thought I would try to print line by line and did this instead:
$result[0] = array(
'node' => $nid,
'title' => $title,
'filename' => end($file),
'directory' => $directory,
// 'orphan' => '?',
);
$output = drush_format_table($result,false,array('node'=>5,'title' => 20,'filename'=>30,'directory'=>25));
drush_print($output);
The problem is, that the output is all over the shop, rather than being lined up nicely as it should be.
Where am I going wrong?
drush vde
.<img>
tags in the middle of my content, then check if the files exist, then find them in the files table, and then update the corresponding entity so that the "use" of the file is registered. Don't see myself doing that in Views!