Completed
Push — master ( b77c5c...4fbeac )
by Jeroen
10s
created

UndeployCommand::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 1
cp 0
rs 9.0856
c 0
b 0
f 0
cc 3
eloc 13
nc 3
nop 2
crap 12
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 UndeployCommand extends AbstractCommand
20
{
21 2
    protected function configure()
22
    {
23
        $this
24 2
            ->setName('undeploy')
25 2
            ->setDescription('Undeploy (use with care!)')
26 2
            ->addArgument('target', InputArgument::REQUIRED, 'Target or group to undeploy')
27 2
            ->addOption('force', '-f', InputOption::VALUE_NONE, 'Force undeploy')
28
        ;
29 2
    }
30
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $conveyor = $this->getConveyor($input, $output, $this->getHelperSet());
34
35
        if (!$input->getOption('force')) {
36
            $answer = $conveyor->getIO()->askConfirmation(
37
                sprintf(
38
                    'Are you sure you want to undeploy? The remote directory "%s" will be removed! ' .
39
                    'Data will be lost! (y/N): ',
40
                    $conveyor->getTransporter($input->getArgument('target'))->getPath()
41
                ),
42
                false
43
            );
44
45
            if (!$answer) {
46
                return;
47
            }
48
        }
49
50
        $options = array();
51
52
        $conveyor->undeploy($input->getArgument('target'), $options);
53
    }
54
}
55