-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
DrupliconCommands.php
47 lines (42 loc) · 1.5 KB
/
DrupliconCommands.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Drush\Commands\core;
use Consolidation\AnnotatedCommand\CommandData;
use Drush\Commands\DrushCommands;
class DrupliconCommands extends DrushCommands
{
protected $printed = false;
/**
* @hook option *
* @option druplicon Shows the druplicon as glorious ASCII art.
*/
public function optionset($options = ['druplicon' => false]): void
{
}
/**
* Print druplicon as post-command output.
*
* @hook post-command *
*/
public function druplicon($result, CommandData $commandData): void
{
// If one command does a Drush::drush() to another command,
// then this hook will be called multiple times. Only print
// once.
if ($this->printed) {
return;
}
$this->printed = true;
$annotationData = $commandData->annotationData();
$commandName = $annotationData['command'];
if ($commandData->input()->hasOption('druplicon') && $commandData->input()->getOption('druplicon')) {
$this->logger()->debug(dt('Displaying Druplicon for "!command" command.', ['!command' => $commandName]));
$misc_dir = DRUSH_BASE_PATH . '/misc';
if ($commandData->input()->getOption('no-ansi')) {
$content = file_get_contents($misc_dir . '/druplicon-no_color.txt');
} else {
$content = file_get_contents($misc_dir . '/druplicon-color.txt');
}
$commandData->output()->writeln($content);
}
}
}