protected function selectApp(InputInterface $input, callable $filter = null)
{
$appName = $input->getOption('app');
if ($appName) {
return $appName;
}
$projectRoot = $this->getProjectRoot();
if (!$projectRoot || !$this->selectedProjectIsCurrent()) {
return null;
}
$this->debug('Searching for applications in local repository');
/** @var LocalApplication[] $apps */
$apps = LocalApplication::getApplications($projectRoot, self::$config);
if ($filter) {
$apps = array_filter($apps, $filter);
}
if (count($apps) > 1 && $input->isInteractive()) {
/** @var \Platformsh\Cli\Helper\QuestionHelper $questionHelper */
$questionHelper = $this->getHelper('question');
$choices = [];
foreach ($apps as $app) {
$choices[$app->getName()] = $app->getName();
}
$appName = $questionHelper->choose($choices, 'Enter a number to choose an app:');
}
$input->setOption('app', $appName);
return $appName;
}