Skip to content

Commit

Permalink
Update installer to support new worker functionality. Closes #1094
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Cryer committed Nov 7, 2015
1 parent 4b8d25c commit 04c67dc
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions PHPCI/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use b8\Store\Factory;
use PHPCI\Helper\Lang;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\DialogHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -46,6 +47,9 @@ protected function configure()
->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass'))
->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email'))
->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath)
->addOption('queue-disabled', null, InputOption::VALUE_NONE, 'Don\'t ask for queue details')
->addOption('queue-server', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname')
->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name')
->setDescription(Lang::get('install_phpci'));
}

Expand Down Expand Up @@ -229,10 +233,37 @@ protected function getPhpciConfigInformation(InputInterface $input, OutputInterf
}

$phpci['url'] = $url;
$phpci['worker'] = $this->getQueueInformation($input, $output, $dialog);

return $phpci;
}

/**
* If the user wants to use a queue, get the necessary details.
* @param InputInterface $input
* @param OutputInterface $output
* @param DialogHelper $dialog
* @return array
*/
protected function getQueueInformation(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
{
if ($input->getOption('queue-disabled')) {
return null;
}

$rtn = [];

if (!$rtn['host'] = $input->getOption('queue-server')) {
$rtn['host'] = $dialog->ask($output, 'Enter your beanstalkd hostname [localhost]: ', 'localhost');
}

if (!$rtn['queue'] = $input->getOption('queue-name')) {
$rtn['queue'] = $dialog->ask($output, 'Enter the queue (tube) name to use [phpci]: ', 'phpci');
}

return $rtn;
}

/**
* Load configuration for DB form CLI options or ask info to user.
*
Expand Down

0 comments on commit 04c67dc

Please sign in to comment.