|
16 | 16 | use b8\Store\Factory;
|
17 | 17 | use PHPCI\Helper\Lang;
|
18 | 18 | use Symfony\Component\Console\Command\Command;
|
| 19 | +use Symfony\Component\Console\Helper\DialogHelper; |
19 | 20 | use Symfony\Component\Console\Input\InputInterface;
|
20 | 21 | use Symfony\Component\Console\Input\InputOption;
|
21 | 22 | use Symfony\Component\Console\Output\OutputInterface;
|
@@ -46,6 +47,9 @@ protected function configure()
|
46 | 47 | ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass'))
|
47 | 48 | ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email'))
|
48 | 49 | ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath)
|
| 50 | + ->addOption('queue-disabled', null, InputOption::VALUE_NONE, 'Don\'t ask for queue details') |
| 51 | + ->addOption('queue-server', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue server hostname') |
| 52 | + ->addOption('queue-name', null, InputOption::VALUE_OPTIONAL, 'Beanstalkd queue name') |
49 | 53 | ->setDescription(Lang::get('install_phpci'));
|
50 | 54 | }
|
51 | 55 |
|
@@ -229,10 +233,37 @@ protected function getPhpciConfigInformation(InputInterface $input, OutputInterf
|
229 | 233 | }
|
230 | 234 |
|
231 | 235 | $phpci['url'] = $url;
|
| 236 | + $phpci['worker'] = $this->getQueueInformation($input, $output, $dialog); |
232 | 237 |
|
233 | 238 | return $phpci;
|
234 | 239 | }
|
235 | 240 |
|
| 241 | + /** |
| 242 | + * If the user wants to use a queue, get the necessary details. |
| 243 | + * @param InputInterface $input |
| 244 | + * @param OutputInterface $output |
| 245 | + * @param DialogHelper $dialog |
| 246 | + * @return array |
| 247 | + */ |
| 248 | + protected function getQueueInformation(InputInterface $input, OutputInterface $output, DialogHelper $dialog) |
| 249 | + { |
| 250 | + if ($input->getOption('queue-disabled')) { |
| 251 | + return null; |
| 252 | + } |
| 253 | + |
| 254 | + $rtn = []; |
| 255 | + |
| 256 | + if (!$rtn['host'] = $input->getOption('queue-server')) { |
| 257 | + $rtn['host'] = $dialog->ask($output, 'Enter your beanstalkd hostname [localhost]: ', 'localhost'); |
| 258 | + } |
| 259 | + |
| 260 | + if (!$rtn['queue'] = $input->getOption('queue-name')) { |
| 261 | + $rtn['queue'] = $dialog->ask($output, 'Enter the queue (tube) name to use [phpci]: ', 'phpci'); |
| 262 | + } |
| 263 | + |
| 264 | + return $rtn; |
| 265 | + } |
| 266 | + |
236 | 267 | /**
|
237 | 268 | * Load configuration for DB form CLI options or ask info to user.
|
238 | 269 | *
|
|
0 commit comments