|
1
|
|
|
<?php |
|
2
|
|
|
/* (c) Anton Medvedev <[email protected]> |
|
3
|
|
|
* |
|
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
5
|
|
|
* file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Deployer\Console; |
|
9
|
|
|
|
|
10
|
|
|
use Deployer\Deployer; |
|
11
|
|
|
use Deployer\Executor\Worker; |
|
12
|
|
|
use Symfony\Component\Console\Command\Command; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption as Option; |
|
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
17
|
|
|
|
|
18
|
|
|
class ConnectCommand extends Command |
|
19
|
|
|
{ |
|
20
|
|
|
protected $deployer; |
|
21
|
|
|
|
|
22
|
12 |
|
public function __construct(Deployer $deployer) |
|
23
|
|
|
{ |
|
24
|
12 |
|
parent::__construct('connect'); |
|
25
|
12 |
|
$this->deployer = $deployer; |
|
26
|
12 |
|
$this->setHidden(true); |
|
27
|
12 |
|
} |
|
28
|
|
|
|
|
29
|
12 |
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
12 |
|
$this->addArgument('connect-host', InputArgument::REQUIRED); |
|
32
|
12 |
|
$this->addOption('decorated', null, Option::VALUE_NONE); |
|
33
|
12 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->deployer->input = $input; |
|
38
|
|
|
$this->deployer->output = $output; |
|
39
|
|
|
$output->setDecorated($input->getOption('decorated')); |
|
40
|
|
|
if (!$output->isDecorated() && !defined('NO_ANSI')) { |
|
41
|
|
|
define('NO_ANSI', 'true'); |
|
42
|
|
|
} |
|
43
|
|
|
$host = $this->deployer->hosts->get($input->getArgument('connect-host')); |
|
44
|
|
|
$this->deployer->sshClient->connect($host); |
|
45
|
|
|
return 0; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|