diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php
index 66144088d..23178e5b7 100644
--- a/src/Composer/Command/UpdateCommand.php
+++ b/src/Composer/Command/UpdateCommand.php
@@ -16,6 +16,7 @@ use Composer\Composer;
use Composer\Installer;
use Composer\Plugin\CommandEvent;
use Composer\Plugin\PluginEvents;
+use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
@@ -188,47 +189,45 @@ EOT
$helper = $this->getHelper('question');
$question = new Question(
- 'Add package that should be updated:',
+ 'Enter package name: ',
null
);
- $confirmation = new ConfirmationQuestion(
- 'Add more packages[yes|no] ? (no) ',
- false
- );
$packages = array();
+ $output->writeln('NB: Empty package ends submission.'); // I couldn't find any better for now!
+
+ $continue = true;
do {
$question->setAutocompleterValues($autocompleterValues);
$addedPackage = $helper->ask($input, $output, $question);
- if (!is_string($addedPackage) || empty($addedPackage)) {
- $output->writeln('Invalid package.');
-
- continue;
- }
-
- if (!in_array($addedPackage, $packages)) {
- $packages[] = $addedPackage;
- if ($addedPackage === $vendorWildcard) {
- $autocompleterValues = array();
+ if (is_string($addedPackage)) {
+ if (!in_array($addedPackage, $packages)) {
+ $packages[] = $addedPackage;
+ if ($addedPackage === $vendorWildcard) {
+ $autocompleterValues = array();
+ } else {
+ $autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
+ }
} else {
- $autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
+ $output->writeln(sprintf('The package "%s" was already added.', $package));
}
} else {
- $output->writeln(sprintf('The package "%s" was already added.', $package));
+ $continue = false;
}
- } while ($helper->ask($input, $output, $confirmation));
+ } while ($continue);
$packages = array_filter($packages);
if (!$packages) {
throw new \InvalidArgumentException('You must enter minimum one package.');
}
- $output->writeln(str_repeat('.', 40));
+ $table = new Table($output);
+ $table->setHeaders(array('Selected packages'));
foreach ((array)$packages as $package) {
- $output->writeln(sprintf('- %s', $package));
+ $table->addRow(array($package));
}
- $output->writeln(str_repeat('.', 40));
+ $table->render();
$continue = new ConfirmationQuestion(
sprintf(