class ExampleCommandsFile

Namespace

Drush\CommandFiles

Hierarchy

Expanded class hierarchy of ExampleCommandsFile

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
ExampleCommandsFile::alterFormatters public function Demonstrate an alter hook with an option
ExampleCommandsFile::exampleTable public function Demonstrate output formatters. Default format is 'table'.

File

lib/Drush/CommandFiles/ExampleCommandsFile.php, line 15
Set up local Drush configuration.

View source
class ExampleCommandsFile extends DrushCommands {
  /**
   * Demonstrate output formatters.  Default format is 'table'.
   *
   * @command example-table
   * @field-labels
   *   first: I
   *   second: II
   *   third: III
   * @default-string-field second
   * @usage example:formatters --format=yaml
   * @usage example:formatters --format=csv
   * @usage example:formatters --fields=first,third
   * @usage example:formatters --fields=III,II
   * @aliases tf
   * @hidden
   *
   * @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields
   */
  public function exampleTable($options =['format' 'table' 'fields' '']) {
    $outputData =['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);
  }

  /**
   * Demonstrate an alter hook with an option
   *
   * @hook alter example-table
   * @option french Add a row with French numbers.
   * @usage example:formatters --french
   */
  public function alterFormatters($result, CommandData $commandData) {
    if ($commandData->input()->getOption('french')) {
      $result['fr'] =['first' 'Un' 'second' 'Deux' 'third' 'Trois'];
    }

    return $result;
  }
}