|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the daikon-cqrs/boot project. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Daikon\Boot\Console; |
|
10
|
|
|
|
|
11
|
|
|
use Daikon\Config\ConfigProviderInterface; |
|
12
|
|
|
use Symfony\Component\Console\Application; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
14
|
|
|
|
|
15
|
|
|
final class Console extends Application |
|
16
|
|
|
{ |
|
17
|
|
|
private ConfigProviderInterface $configProvider; |
|
18
|
|
|
|
|
19
|
|
|
public static function getLogo(): string |
|
20
|
|
|
{ |
|
21
|
|
|
return <<<ASCII |
|
22
|
|
|
____ ____ ____ _____ __ ______ |
|
23
|
|
|
/ __ \/ __ \/ __ \/ ___// / / / _/ |
|
24
|
|
|
/ / / / /_/ / / / /\__ \/ /_/ // / |
|
25
|
|
|
/ /_/ / _, _/ /_/ /___/ / __ // / |
|
26
|
|
|
\____/_/ |_|\____//____/_/ /_/___/ |
|
27
|
|
|
|
|
28
|
|
|
ASCII; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function __construct( |
|
32
|
|
|
ConfigProviderInterface $configProvider, |
|
33
|
|
|
array $consoleCommands = [] |
|
34
|
|
|
) { |
|
35
|
|
|
$this->configProvider = $configProvider; |
|
36
|
|
|
|
|
37
|
|
|
parent::__construct( |
|
38
|
|
|
(string)$configProvider->get('project.name'), |
|
39
|
|
|
sprintf('%s@%s', $configProvider->get('project.version'), $configProvider->get('app.env')) |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
|
|
$this->getDefinition()->addOption( |
|
43
|
|
|
new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name.', 'dev') |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
foreach ($consoleCommands as $command) { |
|
47
|
|
|
$this->add($command); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getHelp(): string |
|
52
|
|
|
{ |
|
53
|
|
|
return self::getLogo().parent::getHelp(); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|