namespace Drupal\Console\Command\Database;
-use Symfony\Component\Console\Input\InputArgument;
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\Console\Generator\DatabaseSettingsGenerator;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Command\Shared\ConnectTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
class AddCommand extends Command
{
- use CommandTrait;
- use ConnectTrait;
-
/**
* @var DatabaseSettingsGenerator
InputOption::VALUE_OPTIONAL,
$this->trans('commands.database.add.options.driver')
)
- ->setHelp($this->trans('commands.database.add.help'));
+ ->setHelp($this->trans('commands.database.add.help'))
+ ->setAliases(['dba']);
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$result = $this
->generator
->generate($input->getOptions());
if (!$result) {
- $io->error($this->trans('commands.database.add.error'));
+ $this->getIo()->error($this->trans('commands.database.add.error'));
}
}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$database = $input->getOption('database');
if (!$database) {
- $database = $io->ask(
+ $database = $this->getIo()->ask(
$this->trans('commands.database.add.questions.database'),
'migrate_db'
);
$input->setOption('database', $database);
$username = $input->getOption('username');
if (!$username) {
- $username = $io->ask(
+ $username = $this->getIo()->ask(
$this->trans('commands.database.add.questions.username'),
''
);
$input->setOption('username', $username);
$password = $input->getOption('password');
if (!$password) {
- $password = $io->ask(
+ $password = $this->getIo()->ask(
$this->trans('commands.database.add.questions.password'),
''
);
$input->setOption('password', $password);
$prefix = $input->getOption('prefix');
if (!$prefix) {
- $prefix = $io->ask(
+ $prefix = $this->getIo()->ask(
$this->trans('commands.database.add.questions.prefix'),
false
);
$input->setOption('prefix', $prefix);
$host = $input->getOption('host');
if (!$host) {
- $host = $io->ask(
+ $host = $this->getIo()->ask(
$this->trans('commands.database.add.questions.host'),
'localhost'
);
$input->setOption('host', $host);
$port = $input->getOption('port');
if (!$port) {
- $port = $io->ask(
+ $port = $this->getIo()->ask(
$this->trans('commands.database.add.questions.port'),
3306
);
$input->setOption('port', $port);
$driver = $input->getOption('driver');
if (!$driver) {
- $driver = $io->ask(
+ $driver = $this->getIo()->ask(
$this->trans('commands.database.add.questions.driver'),
'mysql'
);