Skip to content

Commit 9f93502

Browse files
#8: If a field's human-readable name differs from its machine name, then show both in the help text output
1 parent 3fc72e5 commit 9f93502

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

commands/core/outputformat.drush.inc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,20 @@ function outputformat_drush_help_alter(&$command) {
253253
// then modify the help for --fields to include
254254
// specific information about the available fields.
255255
if (isset($outputformat['field-labels'])) {
256-
$all_fields = array_keys($outputformat['field-labels']);
256+
$all_fields = array();
257+
$all_fields_description = array();
258+
foreach ($outputformat['field-labels'] as $field => $human_readable) {
259+
$all_fields[] = $field;
260+
if ((strtolower($field) != strtolower($human_readable)) && !array_key_exists(strtolower($human_readable), $outputformat['field-labels'])) {
261+
$all_fields_description[] = $field . dt(" (or '!other')", array('!other' => strtolower($human_readable)));
262+
}
263+
else {
264+
$all_fields_description[] = $field;
265+
}
266+
}
257267
$field_defaults = isset($outputformat['fields-default']) ? $outputformat['fields-default'] : $all_fields;
258268
$command['options']['fields']['example-value'] = implode(', ', $field_defaults);
259-
$command['options']['fields']['description'] .= ' '. dt('All available fields are: !fields.', array('!fields' => implode(', ', $all_fields)));
269+
$command['options']['fields']['description'] .= ' '. dt('All available fields are: !fields.', array('!fields' => implode(', ', $all_fields_description)));
260270
if (isset($outputformat['fields-default'])) {
261271
$command['options']['full']['description'] = dt("Show the full output, with all fields included.");
262272
}

0 commit comments

Comments
 (0)