Version 1
[yaffs-website] / vendor / drush / drush / lib / Drush / CommandFiles / ExampleCommandFile.php
1 <?php
2 namespace Drush\CommandFiles;
3
4 /**
5  * @file
6  *   Set up local Drush configuration.
7  */
8
9 use Drush\Log\LogLevel;
10 use Consolidation\AnnotatedCommand\AnnotationData;
11 use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
12
13 use Consolidation\AnnotatedCommand\CommandData;
14
15 class ExampleCommandFile
16 {
17     /**
18      * Demonstrate Robo formatters.  Default format is 'table'.
19      *
20      * @field-labels
21      *   first: I
22      *   second: II
23      *   third: III
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
29      * @aliases tf
30      *
31      * @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields
32      */
33     public function exampleTable($options = ['format' => 'table', 'fields' => ''])
34     {
35         $outputData = [
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'  ],
40         ];
41         return new RowsOfFields($outputData);
42     }
43
44     /**
45      * Demonstrate an alter hook with an option
46      *
47      * @hook alter example:table
48      * @option french Add a row with French numbers.
49      * @usage example:formatters --french
50      */
51     public function alterFormatters($result, CommandData $commandData)
52     {
53         if ($commandData->input()->getOption('french')) {
54             $result['fr'] = [ 'first' => 'Un',  'second' => 'Deux',  'third' => 'Trois'  ];
55         }
56
57         return $result;
58     }
59 }