protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateInput($input);
$sshUrl = $this->getSelectedEnvironment()->getSshUrl($this->selectApp($input));
if ($input->getOption('pipe')) {
$output->write($sshUrl);
return 0;
}
$remoteCommand = $input->getArgument('cmd');
if (!$remoteCommand && $this->runningViaMulti) {
throw new \InvalidArgumentException('The cmd argument is required when running via "multi"');
}
$sshOptions = 't';
// Pass through the verbosity options to SSH.
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
$sshOptions .= 'vv';
} elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
$sshOptions .= 'v';
} elseif ($output->getVerbosity() <= OutputInterface::VERBOSITY_QUIET) {
$sshOptions .= 'q';
}
$command = "ssh -{$sshOptions} " . escapeshellarg($sshUrl);
if ($remoteCommand) {
$command .= ' ' . escapeshellarg($remoteCommand);
}
return $this->getHelper('shell')->executeSimple($command);
}