1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Dandelion\Console\Command; |
6
|
|
|
|
7
|
|
|
use Dandelion\Operation\ReleaserInterface; |
8
|
|
|
use InvalidArgumentException; |
9
|
|
|
use Symfony\Component\Console\Command\Command; |
10
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
13
|
|
|
|
14
|
|
|
use function is_string; |
15
|
|
|
|
16
|
|
|
class ReleaseCommand extends Command |
17
|
|
|
{ |
18
|
|
|
public const NAME = 'release'; |
19
|
|
|
public const DESCRIPTION = 'Releases package.'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var \Dandelion\Operation\ReleaserInterface |
23
|
|
|
*/ |
24
|
|
|
protected $releaser; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param \Dandelion\Operation\ReleaserInterface $releaser |
28
|
|
|
*/ |
29
|
|
|
public function __construct( |
30
|
|
|
ReleaserInterface $releaser |
31
|
|
|
) { |
32
|
|
|
parent::__construct(); |
33
|
|
|
$this->releaser = $releaser; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
protected function configure(): void |
40
|
|
|
{ |
41
|
|
|
parent::configure(); |
42
|
|
|
|
43
|
|
|
$this->setName(static::NAME); |
44
|
|
|
$this->setDescription(static::DESCRIPTION); |
45
|
|
|
|
46
|
|
|
$this->addArgument('repositoryName', InputArgument::REQUIRED, 'Name of split repository'); |
47
|
|
|
$this->addArgument('branch', InputArgument::REQUIRED, 'Branch'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
52
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
53
|
|
|
* |
54
|
|
|
* @return int |
55
|
|
|
*/ |
56
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
57
|
|
|
{ |
58
|
|
|
$repositoryName = $input->getArgument('repositoryName'); |
59
|
|
|
$branch = $input->getArgument('branch'); |
60
|
|
|
|
61
|
|
|
if (!is_string($repositoryName) || !is_string($branch)) { |
62
|
|
|
throw new InvalidArgumentException('Unsupported type for given argument'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$this->releaser->executeForSingleRepository($repositoryName, $branch); |
66
|
|
|
|
67
|
|
|
return 0; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|