use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Drupal\Core\Config\CachedStorage;
use Drupal\Core\Config\ConfigManager;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
class DiffCommand extends Command
{
- use CommandTrait;
-
/**
* @var CachedStorage
*/
null,
InputOption::VALUE_NONE,
$this->trans('commands.config.diff.options.reverse')
- );
+ )->setAliases(['cdi']);
}
/**
protected function interact(InputInterface $input, OutputInterface $output)
{
global $config_directories;
- $io = new DrupalStyle($input, $output);
$directory = $input->getArgument('directory');
if (!$directory) {
- $directory = $io->choice(
+ $directory = $this->getIo()->choice(
$this->trans('commands.config.diff.questions.directories'),
- array_keys($config_directories),
+ $config_directories,
CONFIG_SYNC_DIRECTORY
);
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
- $directory = $input->getArgument('directory');
+ global $config_directories;
+ $directory = $input->getArgument('directory') ?: CONFIG_SYNC_DIRECTORY;
+ if (array_key_exists($directory, $config_directories)) {
+ $directory = $config_directories[$directory];
+ }
$source_storage = new FileStorage($directory);
if ($input->getOption('reverse')) {
$change_list[$collection] = $config_comparer->getChangelist(null, $collection);
}
- $this->outputDiffTable($io, $change_list);
+ $this->outputDiffTable($change_list);
}
/**
* Ouputs a table of configuration changes.
*
- * @param DrupalStyle $io
- * The io.
* @param array $change_list
* The list of changes from the StorageComparer.
*/
- protected function outputDiffTable(DrupalStyle $io, array $change_list)
+ protected function outputDiffTable(array $change_list)
{
$header = [
$this->trans('commands.config.diff.table.headers.collection'),
}
}
}
- $io->table($header, $rows);
+ $this->getIo()->table($header, $rows);
}
}