1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Conveyor package. |
5
|
|
|
* |
6
|
|
|
* (c) Jeroen Fiege <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Webcreate\Conveyor\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
class SimulateCommand extends AbstractCommand |
20
|
|
|
{ |
21
|
2 |
|
protected function configure() |
22
|
|
|
{ |
23
|
|
|
$this |
24
|
2 |
|
->setName('simulate') |
25
|
2 |
|
->setDescription('Simulate a deploy') |
26
|
2 |
|
->addArgument('target', InputArgument::REQUIRED, 'Target or group to simulate') |
27
|
2 |
|
->addArgument('version', InputArgument::REQUIRED, 'Version to simulate') |
28
|
2 |
|
->addOption('force', '-f', InputOption::VALUE_NONE, 'Force deploy') |
29
|
2 |
|
->addOption('full', null, InputOption::VALUE_NONE, 'Full deploy instead of incremental deploy') |
30
|
|
|
; |
31
|
2 |
|
} |
32
|
|
|
|
33
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
34
|
|
|
{ |
35
|
|
|
$conveyor = $this->getConveyor($input, $output, $this->getHelperSet()); |
36
|
|
|
|
37
|
|
|
$options = array(); |
38
|
|
|
$options['full_deploy'] = (bool) $input->getOption('full'); |
39
|
|
|
$options['force'] = (bool) $input->getOption('force'); |
40
|
|
|
|
41
|
|
|
$target = $input->getArgument('target'); |
42
|
|
|
$targets = [$target]; |
43
|
|
|
|
44
|
|
View Code Duplication |
if (false !== strpos($target, ',')) { |
|
|
|
|
45
|
|
|
$output->writeln('<info>Deprecated: Comma-separated list of targets is no longer supported, please use target groups to deploy to multiple targets at once.</info>'); |
46
|
|
|
|
47
|
|
|
$targets = explode(',', $target); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
foreach ($targets as $target) { |
51
|
|
|
$conveyor->simulate($target, $input->getArgument('version'), $options); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.