2 namespace Drush\CommandFiles;
6 * Set up local Drush configuration.
9 use Drush\Log\LogLevel;
10 use Consolidation\AnnotatedCommand\AnnotationData;
11 use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
13 use Consolidation\AnnotatedCommand\CommandData;
15 class ExampleCommandFile
18 * Demonstrate Robo formatters. Default format is 'table'.
24 * @default-string-field second
25 * @usage example:formatters --format=yaml
26 * @usage example:formatters --format=csv
27 * @usage example:formatters --fields=first,third
28 * @usage example:formatters --fields=III,II
31 * @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields
33 public function exampleTable($options = ['format' => 'table', 'fields' => ''])
36 'en' => [ 'first' => 'One', 'second' => 'Two', 'third' => 'Three' ],
37 'de' => [ 'first' => 'Eins', 'second' => 'Zwei', 'third' => 'Drei' ],
38 'jp' => [ 'first' => 'Ichi', 'second' => 'Ni', 'third' => 'San' ],
39 'es' => [ 'first' => 'Uno', 'second' => 'Dos', 'third' => 'Tres' ],
41 return new RowsOfFields($outputData);
45 * Demonstrate an alter hook with an option
47 * @hook alter example:table
48 * @option french Add a row with French numbers.
49 * @usage example:formatters --french
51 public function alterFormatters($result, CommandData $commandData)
53 if ($commandData->input()->getOption('french')) {
54 $result['fr'] = [ 'first' => 'Un', 'second' => 'Deux', 'third' => 'Trois' ];