2 namespace Drush\CommandFiles\core;
4 use Consolidation\AnnotatedCommand\CommandData;
6 class DrupliconCommands {
7 protected $printed = false;
10 * Print druplicon as post-command output.
12 * @hook post-command *
13 * @option druplicon Shows the druplicon as glorious ASCII art.
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)
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') {
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');
37 $content = file_get_contents($misc_dir . '/druplicon-color.txt');
39 drush_print($content);