Refactor the loop + add private method isInteractive
parent
dd9e208bc7
commit
1a82ecad91
|
@ -79,17 +79,20 @@ EOT
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
|
||||||
$packages = $input->getArgument('packages');
|
|
||||||
if ($input->getOption('interactive')) {
|
|
||||||
$packages = $this->getPackagesInteractively($input, $output, $composer, $packages);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($input->getOption('no-custom-installers')) {
|
if ($input->getOption('no-custom-installers')) {
|
||||||
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
$output->writeln('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
|
||||||
$input->setOption('no-plugins', true);
|
$input->setOption('no-plugins', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||||
|
|
||||||
|
$packages = $input->getArgument('packages');
|
||||||
|
|
||||||
|
if ($this->isInteractive($input)) {
|
||||||
|
$packages = $this->getPackagesInteractively($input, $output, $composer, $packages);
|
||||||
|
}
|
||||||
|
|
||||||
|
$composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
|
|
||||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
|
||||||
|
@ -177,22 +180,21 @@ EOT
|
||||||
$packages = is_array($packages) ? $packages : array();
|
$packages = is_array($packages) ? $packages : array();
|
||||||
$output->writeln('<info>NB: Empty package ends submission.</info>'); // I couldn't find any better for now!
|
$output->writeln('<info>NB: Empty package ends submission.</info>'); // I couldn't find any better for now!
|
||||||
|
|
||||||
$continue = true;
|
|
||||||
do {
|
do {
|
||||||
$question->setAutocompleterValues($autocompleterValues);
|
$question->setAutocompleterValues($autocompleterValues);
|
||||||
$addedPackage = $helper->ask($input, $output, $question);
|
$addedPackage = $helper->ask($input, $output, $question);
|
||||||
|
|
||||||
if (is_string($addedPackage)) {
|
if (!is_string($addedPackage)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array($addedPackage, $packages)) {
|
if (!in_array($addedPackage, $packages)) {
|
||||||
$packages[] = $addedPackage;
|
$packages[] = $addedPackage;
|
||||||
$autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
|
$autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
|
||||||
} else {
|
} else {
|
||||||
$output->writeln(sprintf('<error>The package "%s" was already added.</error>', $package));
|
$output->writeln(sprintf('<error>The package "%s" was already added.</error>', $package));
|
||||||
}
|
}
|
||||||
} else {
|
} while (true);
|
||||||
$continue = false;
|
|
||||||
}
|
|
||||||
} while ($continue);
|
|
||||||
|
|
||||||
$packages = array_filter($packages);
|
$packages = array_filter($packages);
|
||||||
if (!$packages) {
|
if (!$packages) {
|
||||||
|
@ -220,4 +222,9 @@ EOT
|
||||||
|
|
||||||
throw new \RuntimeException('Installation aborted.');
|
throw new \RuntimeException('Installation aborted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isInteractive($input)
|
||||||
|
{
|
||||||
|
return $input->getOption('interactive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue