32 lines
748 B
PHP
32 lines
748 B
PHP
<?php
|
|
|
|
namespace App\Console;
|
|
|
|
use App\Service\DatabaseService;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class ListDatabasesCommand extends Command
|
|
{
|
|
protected static $defaultName = 'db:list';
|
|
|
|
public function __construct(
|
|
private DatabaseService $db,
|
|
)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$dbs = $this->db->listDatabases();
|
|
|
|
$output->writeln('List of databases:');
|
|
foreach ($dbs as $db) {
|
|
$output->writeln(sprintf(' -%s', $db));
|
|
}
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
} |