Simplified questionnaire
parent
aca619e130
commit
6fff09c82a
|
@ -16,6 +16,7 @@ use Composer\Composer;
|
||||||
use Composer\Installer;
|
use Composer\Installer;
|
||||||
use Composer\Plugin\CommandEvent;
|
use Composer\Plugin\CommandEvent;
|
||||||
use Composer\Plugin\PluginEvents;
|
use Composer\Plugin\PluginEvents;
|
||||||
|
use Symfony\Component\Console\Helper\Table;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
@ -188,47 +189,45 @@ EOT
|
||||||
|
|
||||||
$helper = $this->getHelper('question');
|
$helper = $this->getHelper('question');
|
||||||
$question = new Question(
|
$question = new Question(
|
||||||
'<comment>Add package that should be updated:</comment>',
|
'<comment>Enter package name: </comment>',
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
$confirmation = new ConfirmationQuestion(
|
|
||||||
'<question>Add more packages[yes|no] ?</question><info> (no) </info> ',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
$packages = array();
|
$packages = array();
|
||||||
|
$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) || empty($addedPackage)) {
|
if (is_string($addedPackage)) {
|
||||||
$output->writeln('<error>Invalid package.</error>');
|
if (!in_array($addedPackage, $packages)) {
|
||||||
|
$packages[] = $addedPackage;
|
||||||
continue;
|
if ($addedPackage === $vendorWildcard) {
|
||||||
}
|
$autocompleterValues = array();
|
||||||
|
} else {
|
||||||
if (!in_array($addedPackage, $packages)) {
|
$autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
|
||||||
$packages[] = $addedPackage;
|
}
|
||||||
if ($addedPackage === $vendorWildcard) {
|
|
||||||
$autocompleterValues = array();
|
|
||||||
} else {
|
} else {
|
||||||
$autocompleterValues = array_diff($autocompleterValues, array($addedPackage));
|
$output->writeln(sprintf('<error>The package "%s" was already added.</error>', $package));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$output->writeln(sprintf('<error>The package "%s" was already added.</error>', $package));
|
$continue = false;
|
||||||
}
|
}
|
||||||
} while ($helper->ask($input, $output, $confirmation));
|
} while ($continue);
|
||||||
|
|
||||||
$packages = array_filter($packages);
|
$packages = array_filter($packages);
|
||||||
if (!$packages) {
|
if (!$packages) {
|
||||||
throw new \InvalidArgumentException('You must enter minimum one package.');
|
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) {
|
foreach ((array)$packages as $package) {
|
||||||
$output->writeln(sprintf('<info>- %s</info>', $package));
|
$table->addRow(array($package));
|
||||||
}
|
}
|
||||||
$output->writeln(str_repeat('.', 40));
|
$table->render();
|
||||||
|
|
||||||
$continue = new ConfirmationQuestion(
|
$continue = new ConfirmationQuestion(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
Loading…
Reference in New Issue