4e58fff794607934d13b0f797aff4429f230a632
[yaffs-website] / vendor / drush / drush / lib / Drush / CommandFiles / core / DrupliconCommands.php
1 <?php
2 namespace Drush\CommandFiles\core;
3
4 use Consolidation\AnnotatedCommand\CommandData;
5
6 class DrupliconCommands {
7   protected $printed = false;
8
9   /**
10    * Print druplicon as post-command output.
11    *
12    * @hook post-command *
13    * @option druplicon Shows the druplicon as glorious ASCII art.
14    */
15   public function druplicon($result, CommandData $commandData) {
16     // If one command does a drush_invoke to another command,
17     // then this hook will be called multiple times. Only print
18     // once.  (n.b. If drush_invoke_process passes along the
19     // --druplicon option, then we will still get mulitple output)
20     if ($this->printed) {
21       return;
22     }
23     $this->printed = true;
24     $annotationData = $commandData->annotationData();
25     $commandName = $annotationData['command'];
26     // For some reason, Drush help uses drush_invoke_process to call helpsingle
27     if ($commandName == 'helpsingle') {
28       return;
29     }
30     drush_log(dt('Displaying Druplicon for "!command" command.', array('!command' => $commandName)));
31     if ($commandData->input()->getOption('druplicon')) {
32       $misc_dir = DRUSH_BASE_PATH . '/misc';
33       if (drush_get_context('DRUSH_NOCOLOR')) {
34         $content = file_get_contents($misc_dir . '/druplicon-no_color.txt');
35       }
36       else {
37         $content = file_get_contents($misc_dir . '/druplicon-color.txt');
38       }
39       drush_print($content);
40     }
41   }
42 }