protected function execute(InputInterface $input, OutputInterface $output)
{
$extensions = $this->callMageScript($input, $output, 'list-available');
if (!strstr($extensions, 'Please initialize Magento Connect installer')) {
$searchString = $input->getArgument('search');
$table = array();
foreach (preg_split('/' . PHP_EOL . '/', $extensions) as $line) {
if (strpos($line, ':') > 0) {
$matches = null;
if ($matches = $this->matchConnectLine($line)) {
if (!empty($searchString) && !stristr($line, $searchString)) {
continue;
}
$table[] = array($matches[1], $matches[2], $matches[3]);
if (isset($matches[4]) && isset($matches[5])) {
$table[] = array($matches[1], $matches[4], $matches[5]);
}
if (isset($matches[6]) && isset($matches[7])) {
$table[] = array($matches[1], $matches[6], $matches[7]);
}
}
}
}
if (count($table) > 0) {
$this->getHelper('table')->setHeaders(array('Package', 'Version', 'Stability'))->renderByFormat($output, $table, $input->getOption('format'));
}
} else {
$output->writeln('<error>' . $extensions . '</error>');
}
}