/**
* @file
- * Contains \Drupal\Console\Core\Command\Site\DebugCommand.
+ * Contains \Drupal\Console\Core\Command\Debug\SiteCommand.
*/
-namespace Drupal\Console\Core\Command\Site;
+namespace Drupal\Console\Core\Command\Debug;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Dumper;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
+use Drupal\Console\Core\Command\Command;
use Drupal\Console\Core\Utils\ConfigurationManager;
-use Drupal\Console\Core\Style\DrupalStyle;
/**
- * Class SiteDebugCommand
+ * Class SiteCommand
*
- * @package Drupal\Console\Core\Command\Site
+ * @package Drupal\Console\Core\Command\Debug
*/
-class DebugCommand extends Command
+class SiteCommand extends Command
{
- use CommandTrait;
-
/**
* @var ConfigurationManager
*/
protected $configurationManager;
/**
- * DebugCommand constructor.
+ * SiteCommand constructor.
*
* @param ConfigurationManager $configurationManager
*/
public function configure()
{
$this
- ->setName('site:debug')
- ->setDescription($this->trans('commands.site.debug.description'))
+ ->setName('debug:site')
+ ->setDescription($this->trans('commands.debug.site.description'))
->addArgument(
'target',
InputArgument::OPTIONAL,
- $this->trans('commands.site.debug.options.target'),
+ $this->trans('commands.debug.site.options.target'),
null
)
->addArgument(
'property',
InputArgument::OPTIONAL,
- $this->trans('commands.site.debug.options.property'),
+ $this->trans('commands.debug.site.options.property'),
null
)
- ->setHelp($this->trans('commands.site.debug.help'));
+ ->setHelp($this->trans('commands.debug.site.help'))
+ ->setAliases(['dsi']);
}
/**
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
- $sites = array_keys($this->configurationManager->getSites());
+ $sites = $this->configurationManager->getSites();
if (!$sites) {
- $io->error($this->trans('commands.site.debug.messages.invalid-sites'));
+ $this->getIo()->warning($this->trans('commands.debug.site.messages.invalid-sites'));
- return 1;
+ return 0;
}
-
- // --target argument
$target = $input->getArgument('target');
if (!$target) {
- $tableHeader =[
- $this->trans('commands.site.debug.messages.site'),
- ];
-
- $io->table($tableHeader, $sites);
+ foreach ($sites as $key => $site) {
+ $environments = array_keys($site);
+ unset($environments[0]);
+
+ $environments = array_map(
+ function ($element) use ($key) {
+ return $key . '.' . $element;
+ },
+ $environments
+ );
+
+ $this->getIo()->info($key);
+ $this->getIo()->listing($environments);
+ }
return 0;
}
$targetConfig = $this->configurationManager->readTarget($target);
if (!$targetConfig) {
- $io->error($this->trans('commands.site.debug.messages.invalid-site'));
+ $this->getIo()->error($this->trans('commands.debug.site.messages.invalid-site'));
return 1;
}
$val = &$val[$property_key];
}
- $io->writeln($val);
+ $this->getIo()->writeln($val);
return 0;
}
- $io->info($target);
+ $this->getIo()->info($target);
$dumper = new Dumper();
- $io->writeln($dumper->dump($targetConfig, 2));
+ $this->getIo()->writeln($dumper->dump($targetConfig, 4, 2));
return 0;
}