Drush: commands/core/outputformat.drush.inc Source File

  1. 7.x doxygen/html/outputformat_8drush_8inc_source.html
  2. master doxygen/html/outputformat_8drush_8inc_source.html
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * @file
5  * Core drush output formats.
6  */
7 
8 /**
9  * @return drush_outputformat The selected output format engine
10  */
12  return drush_get_engine('outputformat');
13 }
14 
15 /**
16  * Dynamically switch to a new output format. Does NOT override
17  * user-selected output format.
18  */
19 function drush_set_default_outputformat($format, $metadata = array()) {
20  $command = drush_get_command();
21  $command['engines']['outputformat']['default'] = $format;
22  $outputformat = drush_load_command_engine($command, 'outputformat', $metadata);
23 }
24 
25 /**
26  * Given a command name or a command record, return the
27  * command formatter that is used to process that command's output.
28  */
29 function drush_get_command_format_metadata($command, $metadata = array()) {
30  $commands = drush_get_commands();
31  if (!is_array($command) && array_key_exists($command, $commands)) {
32  $command = $commands[$command];
33  }
34  return drush_get_command_engine_config($command, 'outputformat', $metadata);
35 }
36 
37 /**
38  * Implementation of hook_drush_engine_type_info().
39  */
41  $info = array();
42  $info['outputformat'] = array(
43  'description' => 'Output formatting options selection and use.',
44  'topic' => 'docs-output-formats',
45  'topic-file' => 'docs/output-formats.html',
46  'combine-help' => TRUE,
47  'option' => 'format',
48  'options' => array(
49  'format' => array(
50  'description' => 'Select output format.',
51  'example-value' => 'json',
52  ),
53  'fields' => array(
54  'description' => 'Fields to output.',
55  'example-value' => 'field1,field2',
56  'value' => 'required',
57  'list' => TRUE,
58  ),
59  'list-separator' => array(
60  'description' => 'Specify how elements in a list should be separated. In lists of lists, this applies to the elements in the inner lists.',
61  'hidden' => TRUE,
62  ),
63  'line-separator' => array(
64  'description' => 'In nested lists of lists, specify how the outer lists ("lines") should be separated.',
65  'hidden' => TRUE,
66  ),
67  'field-labels' => array(
68  'description' => 'Add field labels before first line of data. Default is on; --field-labels=0 to disable.',
69  'default' => '1',
70  'key' => 'include-field-labels',
71  ),
72  ),
73  // Allow output formats to declare their
74  // "output data type" instead of their
75  // "required engine capability" for readability.
76  'config-aliases' => array(
77  'output-data-type' => 'require-engine-capability',
78  ),
79  );
80  return $info;
81 }
82 
83 /**
84  * Implements hook_drush_engine_ENGINE_TYPE().
85  *
86  * The output format types supported are represented by
87  * the 'engine-capabilities' of the output format engine.
88  * The different capabilities include:
89  *
90  * format-single: A simple string.
91  *
92  * format-list: An associative array where the key
93  * is usually the row label, and the value
94  * is a simple string. Some list formatters
95  * render the label, and others (like
96  * "list" and "csv") throw it away.
97  *
98  * format-table: An associative array, where the key
99  * is the row id, and the value is the
100  * column data. The column data is also
101  * an associative array where the key
102  * is the column id and the value is the
103  * cell data. The cell data should usually
104  * be a simple string; however, some
105  * formatters can recursively format their
106  * cell contents before rendering (e.g. if
107  * a cell contains a list of items in an array).
108  *
109  * These definitions align with the declared 'output-data-type'
110  * declared in command records. @see drush_parse_command().
111  *
112  * Any output format that does not declare any engine capabilities
113  * is expected to be able to render any php data structure that is
114  * passed to it.
115  */
117  $common_topic_example = array(
118  "a" => array("b" => 2, "c" => 3),
119  "d" => array("e" => 5, "f" => 6)
120  );
121 
122  $engines = array();
123  $engines['table'] = array(
124  'description' => 'A formatted, word-wrapped table.',
125  'engine-capabilities' => array('format-table'),
126  );
127  $engines['key-value'] = array(
128  'description' => 'A formatted list of key-value pairs.',
129  'engine-capabilities' => array('format-single', 'format-list', 'format-table'),
130  'hidden' => TRUE,
131  );
132  $engines['key-value-list'] = array(
133  'engine-class' => 'list',
134  'list-item-type' => 'key-value',
135  'description' => 'A list of formatted lists of key-value pairs.',
136  'list-field-selection-control' => 1,
137  'engine-capabilities' => array('format-table'),
138  'hidden' => TRUE,
139  );
140  $engines['json'] = array(
141  'machine-parsable' => TRUE,
142  'description' => 'Javascript Object Notation.',
143  'topic-example' => $common_topic_example,
144  );
145  $engines['string'] = array(
146  'machine-parsable' => TRUE,
147  'description' => 'A simple string.',
148  'engine-capabilities' => array('format-single'),
149  );
150  $engines['message'] = array(
151  'machine-parsable' => FALSE, // depends on the label....
152  'hidden' => TRUE,
153  );
154  $engines['print-r'] = array(
155  'machine-parsable' => TRUE,
156  'description' => 'Output via php print_r function.',
157  'verbose-only' => TRUE,
158  'topic-example' => $common_topic_example,
159  );
160  $engines['var_export'] = array(
161  'machine-parsable' => TRUE,
162  'description' => 'An array in executable php format.',
163  'topic-example' => $common_topic_example,
164  );
165  $engines['yaml'] = array(
166  'machine-parsable' => TRUE,
167  'description' => 'Yaml output format.',
168  'topic-example' => $common_topic_example,
169  );
170  $engines['php'] = array(
171  'machine-parsable' => TRUE,
172  'description' => 'A serialized php string.',
173  'verbose-only' => TRUE,
174  'topic-example' => $common_topic_example,
175  );
176  $engines['config'] = array(
177  'machine-parsable' => TRUE,
178  'engine-class' => 'list',
179  'list-item-type' => 'var_export',
180  'description' => "A configuration file in executable php format. The variable name is \"config\", and the variable keys are taken from the output data array's keys.",
181  'metadata' => array(
182  'variable-name' => 'config',
183  ),
184  'list-field-selection-control' => -1,
185  'engine-capabilities' => array('format-list','format-table'),
186  'verbose-only' => TRUE,
187  );
188  $engines['list'] = array(
189  'machine-parsable' => TRUE,
190  'list-item-type' => 'string',
191  'description' => 'A simple list of values.',
192  // When a table is printed as a list, only the array keys of the rows will print.
193  'engine-capabilities' => array('format-list', 'format-table'),
194  'topic-example' => array('a', 'b', 'c'),
195  );
196  $engines['nested-csv'] = array(
197  'machine-parsable' => TRUE,
198  'engine-class' => 'list',
199  'list-separator' => ',',
200  'list-item-type' => 'csv-or-string',
201  'hidden' => TRUE,
202  );
203  $engines['csv-or-string'] = array(
204  'machine-parsable' => TRUE,
205  'hidden' => TRUE,
206  );
207  $engines['csv'] = array(
208  'machine-parsable' => TRUE,
209  'engine-class' => 'list',
210  'list-item-type' => 'nested-csv',
211  'labeled-list' => TRUE,
212  'description' => 'A list of values, one per row, each of which is a comma-separated list of values.',
213  'engine-capabilities' => array('format-table'),
214  'topic-example' => array(array('a', 12, 'a@one.com'),array('b', 17, 'b@two.com')),
215  );
216  $engines['variables'] = array(
217  'machine-parsable' => TRUE,
218  'description' => 'A list of php variable assignments.',
219  'engine-capabilities' => array('format-table'),
220  'verbose-only' => TRUE,
221  'list-field-selection-control' => -1,
222  'topic-example' => $common_topic_example,
223  );
224  $engines['labeled-export'] = array(
225  'machine-parsable' => TRUE,
226  'description' => 'A list of php exports, labeled with a name.',
227  'engine-capabilities' => array('format-table'),
228  'verbose-only' => TRUE,
229  'engine-class' => 'list',
230  'list-item-type' => 'var_export',
231  'metadata' => array(
232  'label-template' => '!label: !value',
233  ),
234  'list-field-selection-control' => -1,
235  'topic-example' => $common_topic_example,
236  );
237  return $engines;
238 }
239 
240 /**
241  * Implements hook_drush_command_alter
242  */
243 function outputformat_drush_command_alter(&$command) {
244  // In --pipe mode, change the default format to the default pipe format, or
245  // to json, if no default pipe format is given.
246  if (drush_get_context('DRUSH_PIPE') && (isset($command['engines']['outputformat']))) {
247  $default_format = isset($command['engines']['outputformat']['pipe-format']) ? $command['engines']['outputformat']['pipe-format'] : 'json';
248  $command['engines']['outputformat']['default'] = $default_format;
249  }
250 }
251 
252 /**
253  * Implements hook_drush_help_alter().
254  */
255 function outputformat_drush_help_alter(&$command) {
256  if (isset($command['engines']['outputformat'])) {
257  $outputformat = $command['engines']['outputformat'];
258  // If the command defines specific field labels,
259  // then modify the help for --fields to include
260  // specific information about the available fields.
261  if (isset($outputformat['field-labels'])) {
262  $all_fields = array();
263  $all_fields_description = array();
264  foreach ($outputformat['field-labels'] as $field => $human_readable) {
265  $all_fields[] = $field;
266  if ((strtolower($field) != strtolower($human_readable)) && !array_key_exists(strtolower($human_readable), $outputformat['field-labels'])) {
267  $all_fields_description[] = $field . dt(" (or '!other')", array('!other' => strtolower($human_readable)));
268  }
269  else {
270  $all_fields_description[] = $field;
271  }
272  }
273  $field_defaults = isset($outputformat['fields-default']) ? $outputformat['fields-default'] : $all_fields;
274  $command['options']['fields']['example-value'] = implode(', ', $field_defaults);
275  $command['options']['fields']['description'] .= ' '. dt('All available fields are: !fields.', array('!fields' => implode(', ', $all_fields_description)));
276  if (isset($outputformat['fields-default'])) {
277  $command['options']['full']['description'] = dt("Show the full output, with all fields included.");
278  }
279  }
280  else {
281  // If the command does not define specific field labels,
282  // then hide the help for --fields unless the command
283  // uses output format engines that format tables.
284  if (isset($outputformat['require-engine-capability']) && is_array($outputformat['require-engine-capability'])) {
285  if (!in_array('format-table', $outputformat['require-engine-capability'])) {
286  unset($command['options']['fields']);
287  unset($command['options']['field-labels']);
288  }
289  }
290  // If the command does define output formats, but does not
291  // define fields, then just hide the help for the --fields option.
292  else {
293  $command['options']['fields']['hidden'] = TRUE;
294  $command['options']['field-labels']['hidden'] = TRUE;
295  }
296  }
297 
298  // If the command defines a default pipe format, then
299  // add '--pipe Equivalent to --format=<pipe-default>'.
300  if (isset($outputformat['pipe-format'])) {
301  if (isset($command['options']['pipe'])) {
302  $command['options']['pipe'] .= ' ';
303  }
304  else {
305  $command['options']['pipe'] = '';
306  }
307  if (isset($outputformat['pipe-metadata']['message-template'])) {
308  $command['options']['pipe'] .= dt('Displays output in the form "!message"', array('!message' => $outputformat['pipe-metadata']['message-template']));
309  }
310  else {
311  $command['options']['pipe'] .= dt("Equivalent to --format=!default.", array('!default' => $outputformat['pipe-format']));
312  }
313  }
314  }
315 }
316 
317 /**
318  * Implements hook_drush_engine_topic_additional_text().
319  */
320 function outputformat_drush_engine_topic_additional_text($engine, $instance, $config) {
321  $result = array();
322 
323  // If the output format engine has a 'topic-example' in
324  // its configuration, then format the provided array using
325  // the output formatter, and insert the result of the
326  // transform into the topic text.
327  if ($engine == 'outputformat') {
328  if (array_key_exists('topic-example', $config)) {
329  $code = $config['topic-example'];
330  $formatted = drush_format($code, array(), $instance);
331  $result[] = dt("Code:\n\nreturn !code;\n\nOutput with --format=!instance:\n\n!formatted", array('!code' => var_export($code, TRUE), '!instance' => $instance, '!formatted' => $formatted));
332  }
333  }
334 
335  return $result;
336 }
337 
338 /**
339  * Interface for output format engines.
340  */
342  function __construct($config) {
343  $config += array(
344  'column-widths' => array(),
345  'field-mappings' => array(),
346  'engine-info' => array(),
347  );
348  $config['engine-info'] += array(
349  'machine-parsable' => FALSE,
350  'metadata' => array(),
351  );
352  $config += $config['engine-info']['metadata'];
353  $this->engine_config = $config;
354  }
355  function format_error($message) {
356  return drush_set_error('DRUSH_FORMAT_ERROR', dt("The output data could not be processed by the selected format '!type'. !message", array('!type' => $this->selected_engine, '!message' => $message)));
357  }
358  function formatter_type() {
359  return $this->engine;
360  }
361  function is_list() {
362  return FALSE;
363  }
364  function formatter_is_simple_list() {
365  if (!isset($this->sub_engine)) {
366  return false;
367  }
368  return ($this->formatter_type() == 'list') && ($this->sub_engine->supports_single_only());
369  }
370  function data_type($metadata) {
371  if (isset($metadata['metameta']['require-engine-capability']) && is_array($metadata['metameta']['require-engine-capability'])) {
372  return $metadata['metameta']['require-engine-capability'][0];
373  }
374  if (isset($metadata['require-engine-capability']) && is_array($metadata['require-engine-capability'])) {
375  return $metadata['require-engine-capability'][0];
376  }
377  return 'unspecified';
378  }
379  function supported_data_types($metadata = NULL) {
380  if ($metadata == NULL) {
381  $metadata = $this->engine_config;
382  }
383  if (isset($metadata['metameta']['engine-info']['engine-capabilities'])) {
384  return $metadata['metameta']['engine-info']['engine-capabilities'];
385  }
386  if (isset($metadata['engine-info']['engine-capabilities'])) {
387  return $metadata['engine-info']['engine-capabilities'];
388  }
389  return array();
390  }
391  function supports_single_only($metadata = NULL) {
392  $supported = $this->supported_data_types($metadata);
393  return (count($supported) == 1) && ($supported[0] == 'format-single');
394  }
395  function get_info($key) {
396  if (array_key_exists($key, $this->engine_config)) {
397  return $this->engine_config[$key];
398  }
399  elseif (isset($this->sub_engine)) {
400  return $this->sub_engine->get_info($key);
401  }
402  return FALSE;
403  }
404  /**
405  * Perform pre-processing and then format() the $input.
406  */
407  function process($input, $metadata = array()) {
408  $metadata = array_merge_recursive($metadata, $this->engine_config);
409  if (isset($metadata['private-fields']) && is_array($input)) {
410  if (!drush_get_option('show-passwords', FALSE)) {
411  if (!is_array($metadata['private-fields'])) {
412  $metadata['private-fields'] = array($metadata['private-fields']);
413  }
414  foreach ($metadata['private-fields'] as $private) {
415  drush_unset_recursive($input, $private);
416  }
417  }
418  }
419  if (isset($metadata[$this->selected_engine . '-metadata'])) {
420  $engine_specific_metadata = $metadata[$this->selected_engine . '-metadata'];
421  unset($metadata[$this->selected_engine . '-metadata']);
422  $metadata = array_merge($metadata, $engine_specific_metadata);
423  }
424  if ((drush_get_context('DRUSH_PIPE')) && (isset($metadata['pipe-metadata']))) {
425  $pipe_specific_metadata = $metadata['pipe-metadata'];
426  unset($metadata['pipe-metadata']);
427  $metadata = array_merge($metadata, $pipe_specific_metadata);
428  }
429  $machine_parsable = $this->engine_config['engine-info']['machine-parsable'];
430  $formatter_type = $machine_parsable ? 'parsable' : 'formatted';
431  if ((!$machine_parsable) && is_bool($input)) {
432  $input = $input ? 'TRUE' : 'FALSE';
433  }
434 
435  // Run $input through any filters that are specified for this formatter.
436  if (isset($metadata[$formatter_type . '-filter'])) {
437  $filters = $metadata[$formatter_type . '-filter'];
438  if (!is_array($filters)) {
439  $filters = array($filters);
440  }
441  foreach ($filters as $filter) {
442  if (function_exists($filter)) {
443  $input = $filter($input, $metadata);
444  }
445  }
446  }
447  if (isset($metadata['field-labels'])) {
448  foreach (drush_hide_output_fields() as $hidden_field) {
449  unset($metadata['field-labels'][$hidden_field]);
450  }
451  }
452  return $this->format($input, $metadata);
453  }
454  function format($input, $metadata) {
455  return $input;
456  }
457 }
458 
459 /**
460  * Specify that certain fields should not appear in the resulting output.
461  */
462 function drush_hide_output_fields($fields_to_hide = array()) {
463  $already_hidden = drush_get_context('DRUSH_HIDDEN_OUTPUT_FIELDS');
464  if (!is_array($fields_to_hide)) {
465  $fields_to_hide = array($fields_to_hide);
466  }
467  $result = array_merge($already_hidden, $fields_to_hide);
468  drush_set_context('DRUSH_HIDDEN_OUTPUT_FIELDS', $result);
469  return $result;
470 }

File

doxygen/html/outputformat_8drush_8inc_source.html
View source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Drush: commands/core/outputformat.drush.inc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Drush
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_afac61274991793aa7e9133a8f4f291e.html">commands</a></li><li class="navelem"><a class="el" href="dir_5762b63965e3a68a35f77c23b4dd4668.html">core</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">outputformat.drush.inc</div>  </div>
</div><!--header-->
<div class="contents">
<a href="outputformat_8drush_8inc.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;?php</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * @file</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *   Core drush output formats.</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * @return drush_outputformat The selected output format engine</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a9b9f691b2f676d97dc57dc3e60f57500">   11</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a9b9f691b2f676d97dc57dc3e60f57500">drush_get_outputformat</a>() {</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="engines_8inc.html#a34ff5c6bb43688e04d0647eddf48d553">drush_get_engine</a>(<span class="stringliteral">&#39;outputformat&#39;</span>);</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;}</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * Dynamically switch to a new output format.  Does NOT override</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * user-selected output format.</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a46f0ffb5f8bf676a5dfec452b083a9f2">   19</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a46f0ffb5f8bf676a5dfec452b083a9f2">drush_set_default_outputformat</a>($format, $metadata = array()) {</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;  $command = <a class="code" href="context_8inc.html#a8fc57227375a540fea5314b154576354">drush_get_command</a>();</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;  $command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>][<span class="stringliteral">&#39;default&#39;</span>] = $format;</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;  $outputformat = <a class="code" href="engines_8inc.html#af4e4689479142932fa789c5e314d29e9">drush_load_command_engine</a>($command, <span class="stringliteral">&#39;outputformat&#39;</span>, $metadata);</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;}</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> * Given a command name or a command record, return the</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> * command formatter that is used to process that command&#39;s output.</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a4a9cc3871032fba8891b665d2606dcc0">   29</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a4a9cc3871032fba8891b665d2606dcc0">drush_get_command_format_metadata</a>($command, $metadata = array()) {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;  $commands = <a class="code" href="includes_2command_8inc.html#af0c377881e5c9c772f0cad80ea016452">drush_get_commands</a>();</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;  <span class="keywordflow">if</span> (!is_array($command) &amp;&amp; array_key_exists($command, $commands)) {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    $command = $commands[$command];</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;  }</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="engines_8inc.html#a316fd3a909b19c6b88ce4ffc521756da">drush_get_command_engine_config</a>($command, <span class="stringliteral">&#39;outputformat&#39;</span>, $metadata);</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;}</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment"> * Implementation of hook_drush_engine_type_info().</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a39c9d1e62b38e743b6131e52a83bbe69">   40</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a39c9d1e62b38e743b6131e52a83bbe69">outputformat_drush_engine_type_info</a>() {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  $info = array();</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  $info[<span class="stringliteral">&#39;outputformat&#39;</span>] = array(</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Output formatting options selection and use.&#39;</span>,</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="stringliteral">&#39;topic&#39;</span> =&gt; <span class="stringliteral">&#39;docs-output-formats&#39;</span>,</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="stringliteral">&#39;topic-file&#39;</span> =&gt; <span class="stringliteral">&#39;docs/output-formats.html&#39;</span>,</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="stringliteral">&#39;combine-help&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="stringliteral">&#39;option&#39;</span> =&gt; <span class="stringliteral">&#39;format&#39;</span>,</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="stringliteral">&#39;options&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;      <span class="stringliteral">&#39;format&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Select output format.&#39;</span>,</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;        <span class="stringliteral">&#39;example-value&#39;</span> =&gt; <span class="stringliteral">&#39;json&#39;</span>,</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;      ),</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;      <span class="stringliteral">&#39;fields&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Fields to output.&#39;</span>,</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <span class="stringliteral">&#39;example-value&#39;</span> =&gt; <span class="stringliteral">&#39;field1,field2&#39;</span>,</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="stringliteral">&#39;value&#39;</span> =&gt; <span class="stringliteral">&#39;required&#39;</span>,</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <span class="stringliteral">&#39;list&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;      ),</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;      <span class="stringliteral">&#39;list-separator&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Specify how elements in a list should be separated. In lists of lists, this applies to the elements in the inner lists.&#39;</span>,</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;      ),</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;      <span class="stringliteral">&#39;line-separator&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;In nested lists of lists, specify how the outer lists (&quot;lines&quot;) should be separated.&#39;</span>,</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      ),</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;      <span class="stringliteral">&#39;field-labels&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Add field labels before first line of data. Default is on; --field-labels=0 to disable.&#39;</span>,</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="charliteral">&#39;1&#39;</span>,</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <span class="stringliteral">&#39;key&#39;</span> =&gt; <span class="stringliteral">&#39;include-field-labels&#39;</span>,</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;      ),</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    ),</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="comment">// Allow output formats to declare their</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <span class="comment">// &quot;output data type&quot; instead of their</span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="comment">// &quot;required engine capability&quot; for readability.</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="stringliteral">&#39;config-aliases&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;      <span class="stringliteral">&#39;output-data-type&#39;</span> =&gt; <span class="stringliteral">&#39;require-engine-capability&#39;</span>,</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    ),</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  );</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  <span class="keywordflow">return</span> $info;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;}</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="comment"> * Implements hook_drush_engine_ENGINE_TYPE().</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="comment"> * The output format types supported are represented by</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="comment"> * the &#39;engine-capabilities&#39; of the output format engine.</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="comment"> * The different capabilities include:</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="comment"> * format-single:       A simple string.</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;<span class="comment"> * format-list:         An associative array where the key</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="comment"> *                      is usually the row label, and the value</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="comment"> *                      is a simple string.  Some list formatters</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="comment"> *                      render the label, and others (like</span></div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="comment"> *                      &quot;list&quot; and &quot;csv&quot;) throw it away.</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<span class="comment"> * format-table:        An associative array, where the key</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="comment"> *                      is the row id, and the value is the</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;<span class="comment"> *                      column data.  The column data is also</span></div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="comment"> *                      an associative array where the key</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;<span class="comment"> *                      is the column id and the value is the</span></div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;<span class="comment"> *                      cell data.  The cell data should usually</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;<span class="comment"> *                      be a simple string; however, some</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="comment"> *                      formatters can recursively format their</span></div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="comment"> *                      cell contents before rendering (e.g. if</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="comment"> *                      a cell contains a list of items in an array).</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;<span class="comment"> * These definitions align with the declared &#39;output-data-type&#39;</span></div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="comment"> * declared in command records.  @see drush_parse_command().</span></div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="comment"> * Any output format that does not declare any engine capabilities</span></div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;<span class="comment"> * is expected to be able to render any php data structure that is</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="comment"> * passed to it.</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00116"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a2b6ff1dbfef77f4ddbebef3c1b5c450c">  116</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a2b6ff1dbfef77f4ddbebef3c1b5c450c">outputformat_drush_engine_outputformat</a>() {</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;  $common_topic_example = array(</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="stringliteral">&quot;a&quot;</span> =&gt; array(<span class="stringliteral">&quot;b&quot;</span> =&gt; 2, <span class="stringliteral">&quot;c&quot;</span> =&gt; 3),</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    <span class="stringliteral">&quot;d&quot;</span> =&gt; array(<span class="stringliteral">&quot;e&quot;</span> =&gt; 5, <span class="stringliteral">&quot;f&quot;</span> =&gt; 6)</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;  );</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;  $engines = array();</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;  $engines[<span class="stringliteral">&#39;table&#39;</span>] = array(</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A formatted, word-wrapped table.&#39;</span>,</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;  );</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  $engines[<span class="stringliteral">&#39;key-value&#39;</span>] = array(</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A formatted list of key-value pairs.&#39;</span>,</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-single&#39;</span>, <span class="stringliteral">&#39;format-list&#39;</span>, <span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  );</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  $engines[<span class="stringliteral">&#39;key-value-list&#39;</span>] = array(</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;    <span class="stringliteral">&#39;engine-class&#39;</span> =&gt; <span class="stringliteral">&#39;list&#39;</span>,</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;key-value&#39;</span>,</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A list of formatted lists of key-value pairs.&#39;</span>,</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    <span class="stringliteral">&#39;list-field-selection-control&#39;</span> =&gt; 1,</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;  );</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;  $engines[<span class="stringliteral">&#39;json&#39;</span>] = array(</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Javascript Object Notation.&#39;</span>,</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;  );</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  $engines[<span class="stringliteral">&#39;string&#39;</span>] = array(</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A simple string.&#39;</span>,</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-single&#39;</span>),</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;  );</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;  $engines[<span class="stringliteral">&#39;message&#39;</span>] = array(</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; FALSE, <span class="comment">// depends on the label....</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  );</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  $engines[<span class="stringliteral">&#39;print-r&#39;</span>] = array(</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Output via php print_r function.&#39;</span>,</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="stringliteral">&#39;verbose-only&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  );</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  $engines[<span class="stringliteral">&#39;var_export&#39;</span>] = array(</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;An array in executable php format.&#39;</span>,</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;  );</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  $engines[<span class="stringliteral">&#39;yaml&#39;</span>] = array(</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;Yaml output format.&#39;</span>,</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  );</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  $engines[<span class="stringliteral">&#39;php&#39;</span>] = array(</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A serialized php string.&#39;</span>,</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    <span class="stringliteral">&#39;verbose-only&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;  );</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;  $engines[<span class="stringliteral">&#39;config&#39;</span>] = array(</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    <span class="stringliteral">&#39;engine-class&#39;</span> =&gt; <span class="stringliteral">&#39;list&#39;</span>,</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;var_export&#39;</span>,</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&quot;A configuration file in executable php format. The variable name is \&quot;config\&quot;, and the variable keys are taken from the output data array&#39;s keys.&quot;</span>,</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    <span class="stringliteral">&#39;metadata&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;      <span class="stringliteral">&#39;variable-name&#39;</span> =&gt; <span class="stringliteral">&#39;config&#39;</span>,</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    ),</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    <span class="stringliteral">&#39;list-field-selection-control&#39;</span> =&gt; -1,</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-list&#39;</span>,<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    <span class="stringliteral">&#39;verbose-only&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;  );</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;  $engines[<span class="stringliteral">&#39;list&#39;</span>] = array(</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;string&#39;</span>,</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A simple list of values.&#39;</span>,</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    <span class="comment">// When a table is printed as a list, only the array keys of the rows will print.</span></div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-list&#39;</span>, <span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; array(<span class="charliteral">&#39;a&#39;</span>, <span class="charliteral">&#39;b&#39;</span>, <span class="charliteral">&#39;c&#39;</span>),</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;  );</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;  $engines[<span class="stringliteral">&#39;nested-csv&#39;</span>] = array(</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    <span class="stringliteral">&#39;engine-class&#39;</span> =&gt; <span class="stringliteral">&#39;list&#39;</span>,</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="stringliteral">&#39;list-separator&#39;</span> =&gt; <span class="charliteral">&#39;,&#39;</span>,</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;csv-or-string&#39;</span>,</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;  );</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;  $engines[<span class="stringliteral">&#39;csv-or-string&#39;</span>] = array(</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <span class="stringliteral">&#39;hidden&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;  );</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;  $engines[<span class="stringliteral">&#39;csv&#39;</span>] = array(</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <span class="stringliteral">&#39;engine-class&#39;</span> =&gt; <span class="stringliteral">&#39;list&#39;</span>,</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;nested-csv&#39;</span>,</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="stringliteral">&#39;labeled-list&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A list of values, one per row, each of which is a comma-separated list of values.&#39;</span>,</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; array(array(<span class="charliteral">&#39;a&#39;</span>, 12, <span class="stringliteral">&#39;a@one.com&#39;</span>),array(<span class="charliteral">&#39;b&#39;</span>, 17, <span class="stringliteral">&#39;b@two.com&#39;</span>)),</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;  );</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;  $engines[<span class="stringliteral">&#39;variables&#39;</span>] = array(</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A list of php variable assignments.&#39;</span>,</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <span class="stringliteral">&#39;verbose-only&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    <span class="stringliteral">&#39;list-field-selection-control&#39;</span> =&gt; -1,</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;  );</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;  $engines[<span class="stringliteral">&#39;labeled-export&#39;</span>] = array(</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    <span class="stringliteral">&#39;description&#39;</span> =&gt; <span class="stringliteral">&#39;A list of php exports, labeled with a name.&#39;</span>,</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    <span class="stringliteral">&#39;engine-capabilities&#39;</span> =&gt; array(<span class="stringliteral">&#39;format-table&#39;</span>),</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    <span class="stringliteral">&#39;verbose-only&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    <span class="stringliteral">&#39;engine-class&#39;</span> =&gt; <span class="stringliteral">&#39;list&#39;</span>,</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="stringliteral">&#39;list-item-type&#39;</span> =&gt; <span class="stringliteral">&#39;var_export&#39;</span>,</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    <span class="stringliteral">&#39;metadata&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;      <span class="stringliteral">&#39;label-template&#39;</span> =&gt; <span class="stringliteral">&#39;!label: !value&#39;</span>,</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    ),</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;    <span class="stringliteral">&#39;list-field-selection-control&#39;</span> =&gt; -1,</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;    <span class="stringliteral">&#39;topic-example&#39;</span> =&gt; $common_topic_example,</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;  );</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;  <span class="keywordflow">return</span> $engines;</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;}</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;<span class="comment"> * Implements hook_drush_command_alter</span></div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00243"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#aa5121e7cdbbb5b10e3186e5f9710d460">  243</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#aa5121e7cdbbb5b10e3186e5f9710d460">outputformat_drush_command_alter</a>(&amp;$command) {</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;  <span class="comment">// In --pipe mode, change the default format to the default pipe format, or</span></div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;  <span class="comment">// to json, if no default pipe format is given.</span></div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;  <span class="keywordflow">if</span> (<a class="code" href="context_8inc.html#ad25559f8d7d753f636fbeac347c29fc5">drush_get_context</a>(<span class="stringliteral">&#39;DRUSH_PIPE&#39;</span>) &amp;&amp; (isset($command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>]))) {</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;    $default_format = isset($command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>][<span class="stringliteral">&#39;pipe-format&#39;</span>]) ? $command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>][<span class="stringliteral">&#39;pipe-format&#39;</span>] : <span class="stringliteral">&#39;json&#39;</span>;</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;    $command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>][<span class="stringliteral">&#39;default&#39;</span>] = $default_format;</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;  }</div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;}</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;<span class="comment"> * Implements hook_drush_help_alter().</span></div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00255"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a57a9881b686a86fc37623da5f972556b">  255</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a57a9881b686a86fc37623da5f972556b">outputformat_drush_help_alter</a>(&amp;$command) {</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;  <span class="keywordflow">if</span> (isset($command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>])) {</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;    $outputformat = $command[<span class="stringliteral">&#39;engines&#39;</span>][<span class="stringliteral">&#39;outputformat&#39;</span>];</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="comment">// If the command defines specific field labels,</span></div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    <span class="comment">// then modify the help for --fields to include</span></div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    <span class="comment">// specific information about the available fields.</span></div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    <span class="keywordflow">if</span> (isset($outputformat[<span class="stringliteral">&#39;field-labels&#39;</span>])) {</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;      $all_fields = array();</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;      $all_fields_description = array();</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;      <span class="keywordflow">foreach</span> ($outputformat[<span class="stringliteral">&#39;field-labels&#39;</span>] as $field =&gt; $human_readable) {</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;        $all_fields[] = $field;</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;        <span class="keywordflow">if</span> ((strtolower($field) != strtolower($human_readable)) &amp;&amp; !array_key_exists(strtolower($human_readable), $outputformat[<span class="stringliteral">&#39;field-labels&#39;</span>])) {</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;          $all_fields_description[] = $field . <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot; (or &#39;!other&#39;)&quot;</span>, array(<span class="stringliteral">&#39;!other&#39;</span> =&gt; strtolower($human_readable)));</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;        }</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;        <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;          $all_fields_description[] = $field;</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;        }</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;      }</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;      $field_defaults = isset($outputformat[<span class="stringliteral">&#39;fields-default&#39;</span>]) ? $outputformat[<span class="stringliteral">&#39;fields-default&#39;</span>] : $all_fields;</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;      $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;fields&#39;</span>][<span class="stringliteral">&#39;example-value&#39;</span>] = implode(<span class="stringliteral">&#39;, &#39;</span>, $field_defaults);</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;      $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;fields&#39;</span>][<span class="stringliteral">&#39;description&#39;</span>] .= <span class="charliteral">&#39; &#39;</span>. <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;All available fields are: !fields.&#39;</span>, array(<span class="stringliteral">&#39;!fields&#39;</span> =&gt; implode(<span class="stringliteral">&#39;, &#39;</span>, $all_fields_description)));</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;      <span class="keywordflow">if</span> (isset($outputformat[<span class="stringliteral">&#39;fields-default&#39;</span>])) {</div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;full&#39;</span>][<span class="stringliteral">&#39;description&#39;</span>] = <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;Show the full output, with all fields included.&quot;</span>);</div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;      }</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;    }</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;      <span class="comment">// If the command does not define specific field labels,</span></div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;      <span class="comment">// then hide the help for --fields unless the command</span></div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;      <span class="comment">// uses output format engines that format tables.</span></div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;      <span class="keywordflow">if</span> (isset($outputformat[<span class="stringliteral">&#39;require-engine-capability&#39;</span>]) &amp;&amp; is_array($outputformat[<span class="stringliteral">&#39;require-engine-capability&#39;</span>])) {</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;        <span class="keywordflow">if</span> (!in_array(<span class="stringliteral">&#39;format-table&#39;</span>, $outputformat[<span class="stringliteral">&#39;require-engine-capability&#39;</span>])) {</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;          unset($command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;fields&#39;</span>]);</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;          unset($command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;field-labels&#39;</span>]);</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;        }</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;      }</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;      <span class="comment">// If the command does define output formats, but does not</span></div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;      <span class="comment">// define fields, then just hide the help for the --fields option.</span></div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;      <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;fields&#39;</span>][<span class="stringliteral">&#39;hidden&#39;</span>] = TRUE;</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;field-labels&#39;</span>][<span class="stringliteral">&#39;hidden&#39;</span>] = TRUE;</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;      }</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    }</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;    <span class="comment">// If the command defines a default pipe format, then</span></div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;    <span class="comment">// add &#39;--pipe   Equivalent to --format=&lt;pipe-default&gt;&#39;.</span></div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;    <span class="keywordflow">if</span> (isset($outputformat[<span class="stringliteral">&#39;pipe-format&#39;</span>])) {</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;      <span class="keywordflow">if</span> (isset($command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;pipe&#39;</span>])) {</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;pipe&#39;</span>] .= <span class="charliteral">&#39; &#39;</span>;</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;      }</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;      <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;pipe&#39;</span>] = <span class="stringliteral">&#39;&#39;</span>;</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;      }</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;      <span class="keywordflow">if</span> (isset($outputformat[<span class="stringliteral">&#39;pipe-metadata&#39;</span>][<span class="stringliteral">&#39;message-template&#39;</span>])) {</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;pipe&#39;</span>] .= <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Displays output in the form &quot;!message&quot;&#39;</span>, array(<span class="stringliteral">&#39;!message&#39;</span> =&gt; $outputformat[<span class="stringliteral">&#39;pipe-metadata&#39;</span>][<span class="stringliteral">&#39;message-template&#39;</span>]));</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;      }</div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;      <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;        $command[<span class="stringliteral">&#39;options&#39;</span>][<span class="stringliteral">&#39;pipe&#39;</span>] .= <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;Equivalent to --format=!default.&quot;</span>, array(<span class="stringliteral">&#39;!default&#39;</span> =&gt; $outputformat[<span class="stringliteral">&#39;pipe-format&#39;</span>]));</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;      }</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;    }</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;  }</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;}</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;<span class="comment"> * Implements hook_drush_engine_topic_additional_text().</span></div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00320"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#a5322ccb6b5616adf4bb2e959e42a214c">  320</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#a5322ccb6b5616adf4bb2e959e42a214c">outputformat_drush_engine_topic_additional_text</a>($engine, $instance, $config) {</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;  $result = array();</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;  <span class="comment">// If the output format engine has a &#39;topic-example&#39; in</span></div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;  <span class="comment">// its configuration, then format the provided array using</span></div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;  <span class="comment">// the output formatter, and insert the result of the</span></div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;  <span class="comment">// transform into the topic text.</span></div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;  <span class="keywordflow">if</span> ($engine == <span class="stringliteral">&#39;outputformat&#39;</span>) {</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;    <span class="keywordflow">if</span> (array_key_exists(<span class="stringliteral">&#39;topic-example&#39;</span>, $config)) {</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;      $code = $config[<span class="stringliteral">&#39;topic-example&#39;</span>];</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;      $formatted = <a class="code" href="group__outputfunctions.html#ga9949217d2df2776bd355c4a3d50bba79">drush_format</a>($code, array(), $instance);</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;      $result[] = <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;Code:\n\nreturn !code;\n\nOutput with --format=!instance:\n\n!formatted&quot;</span>, array(<span class="stringliteral">&#39;!code&#39;</span> =&gt; var_export($code, TRUE), <span class="stringliteral">&#39;!instance&#39;</span> =&gt; $instance, <span class="stringliteral">&#39;!formatted&#39;</span> =&gt; $formatted));</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;    }</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;  }</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;  <span class="keywordflow">return</span> $result;</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;}</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;<span class="comment"> * Interface for output format engines.</span></div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00341"></a><span class="lineno"><a class="code" href="classdrush__outputformat.html">  341</a></span>&#160;<span class="keyword">class </span><a class="code" href="classdrush__outputformat.html">drush_outputformat</a> {</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;  <span class="keyword">function</span> __construct($config) {</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;    $config += array(</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;      <span class="stringliteral">&#39;column-widths&#39;</span> =&gt; array(),</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;      <span class="stringliteral">&#39;field-mappings&#39;</span> =&gt; array(),</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;      <span class="stringliteral">&#39;engine-info&#39;</span> =&gt; array(),</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;    );</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;    $config[<span class="stringliteral">&#39;engine-info&#39;</span>] += array(</div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;      <span class="stringliteral">&#39;machine-parsable&#39;</span> =&gt; FALSE,</div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;      <span class="stringliteral">&#39;metadata&#39;</span> =&gt; array(),</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    );</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;    $config += $config[<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;metadata&#39;</span>];</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;    $this-&gt;engine_config = $config;</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;  }</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;  <span class="keyword">function</span> format_error($message) {</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<span class="stringliteral">&#39;DRUSH_FORMAT_ERROR&#39;</span>, <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;The output data could not be processed by the selected format &#39;!type&#39;.  !message&quot;</span>, array(<span class="stringliteral">&#39;!type&#39;</span> =&gt; $this-&gt;selected_engine, <span class="stringliteral">&#39;!message&#39;</span> =&gt; $message)));</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;  }</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;  <span class="keyword">function</span> formatter_type() {</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;    <span class="keywordflow">return</span> $this-&gt;engine;</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;  }</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;  <span class="keyword">function</span> is_list() {</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;    <span class="keywordflow">return</span> FALSE;</div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;  }</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;  <span class="keyword">function</span> formatter_is_simple_list() {</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;    <span class="keywordflow">if</span> (!isset($this-&gt;sub_engine)) {</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;    }</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;    <span class="keywordflow">return</span> ($this-&gt;formatter_type() == <span class="stringliteral">&#39;list&#39;</span>) &amp;&amp; ($this-&gt;sub_engine-&gt;supports_single_only());</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;  }</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;  <span class="keyword">function</span> data_type($metadata) {</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;metameta&#39;</span>][<span class="stringliteral">&#39;require-engine-capability&#39;</span>]) &amp;&amp; is_array($metadata[<span class="stringliteral">&#39;metameta&#39;</span>][<span class="stringliteral">&#39;require-engine-capability&#39;</span>])) {</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;      <span class="keywordflow">return</span>  $metadata[<span class="stringliteral">&#39;metameta&#39;</span>][<span class="stringliteral">&#39;require-engine-capability&#39;</span>][0];</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;    }</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;require-engine-capability&#39;</span>]) &amp;&amp; is_array($metadata[<span class="stringliteral">&#39;require-engine-capability&#39;</span>])) {</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;      <span class="keywordflow">return</span>  $metadata[<span class="stringliteral">&#39;require-engine-capability&#39;</span>][0];</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;    }</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;    <span class="keywordflow">return</span> <span class="stringliteral">&#39;unspecified&#39;</span>;</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;  }</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;  <span class="keyword">function</span> supported_data_types($metadata = NULL) {</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    <span class="keywordflow">if</span> ($metadata == NULL) {</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;      $metadata = $this-&gt;engine_config;</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;    }</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;metameta&#39;</span>][<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;engine-capabilities&#39;</span>])) {</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;      <span class="keywordflow">return</span>  $metadata[<span class="stringliteral">&#39;metameta&#39;</span>][<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;engine-capabilities&#39;</span>];</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;    }</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;engine-capabilities&#39;</span>])) {</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;      <span class="keywordflow">return</span>  $metadata[<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;engine-capabilities&#39;</span>];</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;    }</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    <span class="keywordflow">return</span> array();</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;  }</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;  <span class="keyword">function</span> supports_single_only($metadata = NULL) {</div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;    $supported = $this-&gt;supported_data_types($metadata);</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    <span class="keywordflow">return</span> (count($supported) == 1) &amp;&amp; ($supported[0] == <span class="stringliteral">&#39;format-single&#39;</span>);</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;  }</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;  <span class="keyword">function</span> get_info($key) {</div>
<div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;    <span class="keywordflow">if</span> (array_key_exists($key, $this-&gt;engine_config)) {</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;      <span class="keywordflow">return</span> $this-&gt;engine_config[$key];</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;    }</div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;    elseif (isset($this-&gt;sub_engine)) {</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;      <span class="keywordflow">return</span> $this-&gt;sub_engine-&gt;get_info($key);</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;    }</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;    <span class="keywordflow">return</span> FALSE;</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;  }<span class="comment"></span></div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;<span class="comment">  /**</span></div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;<span class="comment">   * Perform pre-processing and then format() the $input.</span></div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;<span class="comment">   */</span></div>
<div class="line"><a name="l00407"></a><span class="lineno"><a class="code" href="classdrush__outputformat.html#a69d8dba156e7b5aabb76fea0f52cfd68">  407</a></span>&#160;  <span class="keyword">function</span> <a class="code" href="classdrush__outputformat.html#a69d8dba156e7b5aabb76fea0f52cfd68">process</a>($input, $metadata = array()) {</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;    $metadata = array_merge_recursive($metadata, $this-&gt;engine_config);</div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;private-fields&#39;</span>]) &amp;&amp; is_array($input)) {</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;      <span class="keywordflow">if</span> (!<a class="code" href="context_8inc.html#afe91fb3e5219ecb2208c3b036b1f0cb8">drush_get_option</a>(<span class="stringliteral">&#39;show-passwords&#39;</span>, FALSE)) {</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;        <span class="keywordflow">if</span> (!is_array($metadata[<span class="stringliteral">&#39;private-fields&#39;</span>])) {</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;          $metadata[<span class="stringliteral">&#39;private-fields&#39;</span>] = array($metadata[<span class="stringliteral">&#39;private-fields&#39;</span>]);</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;        }</div>
<div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;        <span class="keywordflow">foreach</span> ($metadata[<span class="stringliteral">&#39;private-fields&#39;</span>] as $private) {</div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;          <a class="code" href="drush_8inc.html#a168e5c4e0711c44cf1c54ea8c4ff2c75">drush_unset_recursive</a>($input, $private);</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;        }</div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;      }</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;    }</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[$this-&gt;selected_engine . <span class="stringliteral">&#39;-metadata&#39;</span>])) {</div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;      $engine_specific_metadata = $metadata[$this-&gt;selected_engine . <span class="stringliteral">&#39;-metadata&#39;</span>];</div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;      unset($metadata[$this-&gt;selected_engine . <span class="stringliteral">&#39;-metadata&#39;</span>]);</div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;      $metadata = array_merge($metadata, $engine_specific_metadata);</div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;    }</div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    <span class="keywordflow">if</span> ((<a class="code" href="context_8inc.html#ad25559f8d7d753f636fbeac347c29fc5">drush_get_context</a>(<span class="stringliteral">&#39;DRUSH_PIPE&#39;</span>)) &amp;&amp; (isset($metadata[<span class="stringliteral">&#39;pipe-metadata&#39;</span>]))) {</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;      $pipe_specific_metadata = $metadata[<span class="stringliteral">&#39;pipe-metadata&#39;</span>];</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;      unset($metadata[<span class="stringliteral">&#39;pipe-metadata&#39;</span>]);</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;      $metadata = array_merge($metadata, $pipe_specific_metadata);</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;    }</div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;    $machine_parsable = $this-&gt;engine_config[<span class="stringliteral">&#39;engine-info&#39;</span>][<span class="stringliteral">&#39;machine-parsable&#39;</span>];</div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;    $formatter_type = $machine_parsable ? <span class="stringliteral">&#39;parsable&#39;</span> : <span class="stringliteral">&#39;formatted&#39;</span>;</div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;    <span class="keywordflow">if</span> ((!$machine_parsable) &amp;&amp; is_bool($input)) {</div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;      $input = $input ? <span class="stringliteral">&#39;TRUE&#39;</span> : <span class="stringliteral">&#39;FALSE&#39;</span>;</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    }</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    <span class="comment">// Run $input through any filters that are specified for this formatter.</span></div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[$formatter_type . <span class="stringliteral">&#39;-filter&#39;</span>])) {</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;      $filters = $metadata[$formatter_type . <span class="stringliteral">&#39;-filter&#39;</span>];</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;      <span class="keywordflow">if</span> (!is_array($filters)) {</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;        $filters = array($filters);</div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;      }</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;      <span class="keywordflow">foreach</span> ($filters as $filter) {</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;        <span class="keywordflow">if</span> (function_exists($filter)) {</div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;          $input = $filter($input, $metadata);</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;        }</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;      }</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;    }</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    <span class="keywordflow">if</span> (isset($metadata[<span class="stringliteral">&#39;field-labels&#39;</span>])) {</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;      <span class="keywordflow">foreach</span> (<a class="code" href="outputformat_8drush_8inc.html#aa114eb117d61d2a796e638caf91f92d6">drush_hide_output_fields</a>() as $hidden_field) {</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;        unset($metadata[<span class="stringliteral">&#39;field-labels&#39;</span>][$hidden_field]);</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;      }</div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;    }</div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;    <span class="keywordflow">return</span> $this-&gt;format($input, $metadata);</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;  }</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;  <span class="keyword">function</span> format($input, $metadata) {</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;    <span class="keywordflow">return</span> $input;</div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;  }</div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;}</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;<span class="comment"> * Specify that certain fields should not appear in the resulting output.</span></div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00462"></a><span class="lineno"><a class="code" href="outputformat_8drush_8inc.html#aa114eb117d61d2a796e638caf91f92d6">  462</a></span>&#160;<span class="keyword">function</span> <a class="code" href="outputformat_8drush_8inc.html#aa114eb117d61d2a796e638caf91f92d6">drush_hide_output_fields</a>($fields_to_hide = array()) {</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;  $already_hidden = <a class="code" href="context_8inc.html#ad25559f8d7d753f636fbeac347c29fc5">drush_get_context</a>(<span class="stringliteral">&#39;DRUSH_HIDDEN_OUTPUT_FIELDS&#39;</span>);</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;  <span class="keywordflow">if</span> (!is_array($fields_to_hide)) {</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;    $fields_to_hide = array($fields_to_hide);</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;  }</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;  $result = array_merge($already_hidden, $fields_to_hide);</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;  <a class="code" href="context_8inc.html#af983acfe90e7d7bbdbd67c57f93708ba">drush_set_context</a>(<span class="stringliteral">&#39;DRUSH_HIDDEN_OUTPUT_FIELDS&#39;</span>, $result);</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;  <span class="keywordflow">return</span> $result;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Oct 8 2014 09:04:53 for Drush by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>