diff --git a/src/Console/BackupDatabaseCommand.php b/src/Console/BackupDatabaseCommand.php index 0376b9f..d458d60 100644 --- a/src/Console/BackupDatabaseCommand.php +++ b/src/Console/BackupDatabaseCommand.php @@ -11,7 +11,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('db:backup')] +#[AsCommand('app:db:backup')] class BackupDatabaseCommand extends Command { use SelectDatabaseQuestion; diff --git a/src/Console/CreateDatabaseCommand.php b/src/Console/CreateDatabaseCommand.php index 019df9c..0f5b397 100644 --- a/src/Console/CreateDatabaseCommand.php +++ b/src/Console/CreateDatabaseCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; -#[AsCommand('db:create')] +#[AsCommand('app:db:create')] class CreateDatabaseCommand extends Command { public function __construct( diff --git a/src/Console/CreateUserCommand.php b/src/Console/CreateUserCommand.php index 07fc68b..dc0da4b 100644 --- a/src/Console/CreateUserCommand.php +++ b/src/Console/CreateUserCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; -#[AsCommand('user:create')] +#[AsCommand('app:user:create')] class CreateUserCommand extends Command { public function __construct( diff --git a/src/Console/DeleteDatabaseCommand.php b/src/Console/DeleteDatabaseCommand.php index 110651f..0aed5b8 100644 --- a/src/Console/DeleteDatabaseCommand.php +++ b/src/Console/DeleteDatabaseCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('db:delete')] +#[AsCommand('app:db:delete')] class DeleteDatabaseCommand extends Command { use SelectDatabaseQuestion; diff --git a/src/Console/DeleteUserCommand.php b/src/Console/DeleteUserCommand.php index 68db6d0..1b852ca 100644 --- a/src/Console/DeleteUserCommand.php +++ b/src/Console/DeleteUserCommand.php @@ -11,7 +11,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\Question; -#[AsCommand('user:delete')] +#[AsCommand('app:user:delete')] class DeleteUserCommand extends Command { public function __construct( diff --git a/src/Console/ListDatabasesCommand.php b/src/Console/ListDatabasesCommand.php index 235cf02..65ef61a 100644 --- a/src/Console/ListDatabasesCommand.php +++ b/src/Console/ListDatabasesCommand.php @@ -7,8 +7,9 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; -#[AsCommand('db:list')] +#[AsCommand('app:db:list')] class ListDatabasesCommand extends Command { public function __construct( @@ -21,11 +22,17 @@ class ListDatabasesCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { $dbs = $this->db->listDatabases(); + $style = new SymfonyStyle($input, $output); - $output->writeln('List of databases:'); + $table = $style + ->createTable() + ->setHeaders(['Name']) + ->setHeaderTitle('List of databases') + ; foreach ($dbs as $db) { - $output->writeln(sprintf(' -%s', $db)); + $table->addRow([$db]); } + $table->render(); return Command::SUCCESS; } diff --git a/src/Console/ListUsersCommand.php b/src/Console/ListUsersCommand.php index 7f0fda2..9a975c5 100644 --- a/src/Console/ListUsersCommand.php +++ b/src/Console/ListUsersCommand.php @@ -7,8 +7,9 @@ use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; -#[AsCommand('user:list')] +#[AsCommand('app:user:list')] class ListUsersCommand extends Command { public function __construct( @@ -20,17 +21,19 @@ class ListUsersCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + $style = new SymfonyStyle($input, $output); + $users = $this->db->listUsers(); - $output->writeln('List of users:'); + $table = $style + ->createTable() + ->setHeaders(['Name', 'Host', 'Plugin']) + ->setHeaderTitle('List of users') + ; foreach ($users as $user) { - $line = sprintf(' -%s @%s', $user['name'], $user['host']); - if (!empty($plugin = $user['plugin'])) { - $line .= sprintf(' (%s)', $plugin); - } - - $output->writeln($line); + $table->addRow([$user['name'], $user['host'], $user['plugin'] ?? '']); } + $table->render(); return Command::SUCCESS; } diff --git a/src/Console/PurgeDatabaseCommand.php b/src/Console/PurgeDatabaseCommand.php index 0b7432a..c4ea6fe 100644 --- a/src/Console/PurgeDatabaseCommand.php +++ b/src/Console/PurgeDatabaseCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -#[AsCommand('db:purge')] +#[AsCommand('app:db:purge')] class PurgeDatabaseCommand extends Command { use SelectDatabaseQuestion; diff --git a/src/Console/RestoreDatabaseCommand.php b/src/Console/RestoreDatabaseCommand.php index 7777495..9caed3c 100644 --- a/src/Console/RestoreDatabaseCommand.php +++ b/src/Console/RestoreDatabaseCommand.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Finder\Finder; -#[AsCommand('db:restore')] +#[AsCommand('app:db:restore')] class RestoreDatabaseCommand extends Command { use SelectDatabaseQuestion;