1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Dandelion\Console\Command; |
6
|
|
|
|
7
|
|
|
use Dandelion\Operation\InitializerInterface; |
8
|
|
|
use Dandelion\Operation\ReleaserInterface; |
9
|
|
|
use Dandelion\Operation\Result\MessageInterface; |
10
|
|
|
use Symfony\Component\Console\Command\Command; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
class InitAllCommand extends Command |
15
|
|
|
{ |
16
|
|
|
public const NAME = 'init:all'; |
17
|
|
|
public const DESCRIPTION = 'Init all split repository on vcs platform.'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var \Dandelion\Operation\InitializerInterface |
21
|
|
|
*/ |
22
|
|
|
protected $initializer; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param \Dandelion\Operation\InitializerInterface $initializer |
26
|
|
|
*/ |
27
|
|
|
public function __construct( |
28
|
|
|
InitializerInterface $initializer |
29
|
|
|
) { |
30
|
|
|
parent::__construct(); |
31
|
|
|
$this->initializer = $initializer; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
protected function configure(): void |
38
|
|
|
{ |
39
|
|
|
parent::configure(); |
40
|
|
|
|
41
|
|
|
$this->setName(static::NAME); |
42
|
|
|
$this->setDescription(static::DESCRIPTION); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
47
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
48
|
|
|
* |
49
|
|
|
* @return int |
50
|
|
|
*/ |
51
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
52
|
|
|
{ |
53
|
|
|
$output->writeln('Init split repositories:'); |
54
|
|
|
$output->writeln('---------------------------------'); |
55
|
|
|
|
56
|
|
|
$result = $this->initializer->executeForAllRepositories([]); |
57
|
|
|
|
58
|
|
|
foreach ($result->getMessages() as $message) { |
59
|
|
|
$symbol = $message->getType() === MessageInterface::TYPE_INFO ? '<fg=green>✔</>' : '<fg=red>✗</>'; |
60
|
|
|
$output->writeln(sprintf('%s %s', $symbol, $message->getText())); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$output->writeln('---------------------------------'); |
64
|
|
|
$output->writeln('Finished'); |
65
|
|
|
|
66
|
|
|
return 0; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|