2016-12-31 21:15:46 +01:00
|
|
|
<?php
|
2022-04-10 06:20:03 +02:00
|
|
|
|
2016-12-31 21:15:46 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Magallanes package.
|
|
|
|
*
|
|
|
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Mage\Command\BuiltIn\Config;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Symfony\Component\Console\Helper\Table;
|
|
|
|
use Mage\Command\AbstractCommand;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command for listing all the Environments
|
|
|
|
*
|
|
|
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
|
|
|
*/
|
|
|
|
class EnvironmentsCommand extends AbstractCommand
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Configure the Command
|
|
|
|
*/
|
2022-04-10 06:20:03 +02:00
|
|
|
protected function configure(): void
|
2016-12-31 21:15:46 +01:00
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setName('config:environments')
|
2022-04-10 06:20:03 +02:00
|
|
|
->setDescription('List all Magallanes configured Environments');
|
2016-12-31 21:15:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the Command
|
|
|
|
*/
|
2022-04-10 06:20:03 +02:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
2016-12-31 21:15:46 +01:00
|
|
|
{
|
2017-01-29 23:25:03 +01:00
|
|
|
$this->requireConfig();
|
|
|
|
|
2016-12-31 21:15:46 +01:00
|
|
|
$output->writeln('Starting <fg=blue>Magallanes</>');
|
|
|
|
$output->writeln('');
|
|
|
|
|
|
|
|
$table = new Table($output);
|
2017-01-04 03:12:19 +01:00
|
|
|
$table->setHeaders(['Environment', 'User', 'Branch', 'Hosts']);
|
2016-12-31 21:15:46 +01:00
|
|
|
|
2017-01-12 02:22:21 +01:00
|
|
|
$configuration = $this->runtime->getConfigOption('environments');
|
2016-12-31 21:15:46 +01:00
|
|
|
foreach ($configuration as $environment => $config) {
|
|
|
|
$row = [$environment];
|
|
|
|
|
|
|
|
$row[] = (isset($config['user']) ? $config['user'] : '-');
|
|
|
|
$row[] = (isset($config['branch']) ? $config['branch'] : '-');
|
|
|
|
$row[] = (isset($config['hosts']) ? implode(PHP_EOL, $config['hosts']) : '-');
|
|
|
|
|
|
|
|
$table->addRow($row);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->render();
|
|
|
|
|
|
|
|
$output->writeln('');
|
|
|
|
$output->writeln('Finished <fg=blue>Magallanes</>');
|
|
|
|
|
2022-04-10 06:20:03 +02:00
|
|
|
return self::SUCCESS;
|
2016-12-31 21:15:46 +01:00
|
|
|
}
|
|
|
|
}
|