2 namespace Drush\Commands\core;
4 use Consolidation\AnnotatedCommand\AnnotationData;
5 use Consolidation\AnnotatedCommand\CommandData;
6 use Drush\Commands\DrushCommands;
7 use Symfony\Component\Console\Command\Command;
8 use Symfony\Component\Console\Input\InputOption;
10 class DrupliconCommands extends DrushCommands
12 protected $printed = false;
16 * @option druplicon Shows the druplicon as glorious ASCII art.
18 public function optionset($options = ['druplicon' => false])
23 * Print druplicon as post-command output.
25 * @hook post-command *
27 public function druplicon($result, CommandData $commandData)
29 // If one command does a drush_invoke to another command,
30 // then this hook will be called multiple times. Only print
31 // once. (n.b. If drush_invoke_process passes along the
32 // --druplicon option, then we still get multiple output)
36 $this->printed = true;
37 $annotationData = $commandData->annotationData();
38 $commandName = $annotationData['command'];
39 if ($commandData->input()->hasOption('druplicon') && $commandData->input()->getOption('druplicon')) {
40 $this->logger()->debug(dt('Displaying Druplicon for "!command" command.', ['!command' => $commandName]));
41 $misc_dir = DRUSH_BASE_PATH . '/misc';
42 if ($commandData->input()->getOption('no-ansi')) {
43 $content = file_get_contents($misc_dir . '/druplicon-no_color.txt');
45 $content = file_get_contents($misc_dir . '/druplicon-color.txt');
47 $commandData->output()->writeln($content);