Skip to content

Commit f94f3c3

Browse files
#52: Automatically set the label separator to the list separator when csv, etc. is selected with @sites (or other multi-site commands)
1 parent 6e902a4 commit f94f3c3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

commands/core/outputformat.drush.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,15 @@ class drush_outputformat {
379379
$supported = $this->supported_data_types($metadata);
380380
return (count($supported) == 1) && ($supported[0] == 'format-single');
381381
}
382+
function get_info($key) {
383+
if (array_key_exists($key, $this->engine_config)) {
384+
return $this->engine_config[$key];
385+
}
386+
elseif (isset($this->sub_engine)) {
387+
return $this->sub_engine->get_info($key);
388+
}
389+
return FALSE;
390+
}
382391
/**
383392
* Perform pre-processing and then format() the $input.
384393
*/

includes/drush.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,29 @@ function drush_preflight_command_dispatch() {
11891189
if (drush_get_option('no-label', FALSE)) {
11901190
$backend_options['no-label'] = TRUE;
11911191
}
1192+
// If the user specified a format, try to look up the
1193+
// default list separator for the specified format.
1194+
// If the user did not specify a different label separator,
1195+
// then pass in the default as an option, so that the
1196+
// separtor between the items in the list and the site
1197+
// name will be consistant.
1198+
$format = drush_get_option('format', FALSE);
1199+
if ($format) {
1200+
$implemented = drush_get_commands();
1201+
if (array_key_exists($command_name, $implemented)) {
1202+
$command = $implemented[$command_name];
1203+
if ($command) {
1204+
$result = drush_load_command_engines($command);
1205+
$formatter = drush_get_outputformat();
1206+
if (!array_key_exists('label-separator', $multi_options)) {
1207+
$list_separator = $formatter->get_info('list-separator');
1208+
if ($list_separator) {
1209+
$multi_options['label-separator'] = $list_separator;
1210+
}
1211+
}
1212+
}
1213+
}
1214+
}
11921215
$values = drush_invoke_process($site_record, $command_name, $args, $multi_options, $backend_options);
11931216
return TRUE;
11941217
}

0 commit comments

Comments
 (0)