X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fdrush%2Fdrush%2Fsrc%2FCommands%2FExampleCommands.php;fp=vendor%2Fdrush%2Fdrush%2Flib%2FDrush%2FCommandFiles%2FExampleCommandFile.php;h=cdb0ea5f0fb6e4db4e129fa7b4fd3ca08479e911;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=ec764dd6f4a795df9bdf5561dd61d5e78eda3ed0;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/drush/drush/lib/Drush/CommandFiles/ExampleCommandFile.php b/vendor/drush/drush/src/Commands/ExampleCommands.php similarity index 51% rename from vendor/drush/drush/lib/Drush/CommandFiles/ExampleCommandFile.php rename to vendor/drush/drush/src/Commands/ExampleCommands.php index ec764dd6f..cdb0ea5f0 100644 --- a/vendor/drush/drush/lib/Drush/CommandFiles/ExampleCommandFile.php +++ b/vendor/drush/drush/src/Commands/ExampleCommands.php @@ -1,5 +1,5 @@ 'table', 'fields' => '']) + public function exampleTable($options = ['format' => 'table']) { - $outputData = [ + $tableData = [ 'en' => [ 'first' => 'One', 'second' => 'Two', 'third' => 'Three' ], 'de' => [ 'first' => 'Eins', 'second' => 'Zwei', 'third' => 'Drei' ], 'jp' => [ 'first' => 'Ichi', 'second' => 'Ni', 'third' => 'San' ], 'es' => [ 'first' => 'Uno', 'second' => 'Dos', 'third' => 'Tres' ], ]; - return new RowsOfFields($outputData); + $data = new RowsOfFields($tableData); + + // Add a render function to transform cell data when the output + // format is a table, or similar. This allows us to add color + // information to the output without modifying the data cells when + // using yaml or json output formats. + $data->addRendererFunction( + // n.b. There is a fourth parameter $rowData that may be added here. + function ($key, $cellData, FormatterOptions $options, $rowData) { + if ($key == 'first') { + return "$cellData"; + } + return $cellData; + } + ); + + return $data; } /** * Demonstrate an alter hook with an option * - * @hook alter example:table + * @hook alter example-table * @option french Add a row with French numbers. - * @usage example:formatters --french + * @usage example-table --french */ public function alterFormatters($result, CommandData $commandData) {