Make database name question more specific
This commit is contained in:
parent
1aad1a59e4
commit
153f04ccd7
@ -26,7 +26,7 @@ class BackupDatabaseCommand extends Command
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('file', InputArgument::OPTIONAL, 'Backup file name');
|
||||
}
|
||||
|
||||
|
@ -22,14 +22,14 @@ class CreateDatabaseCommand extends Command
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$question = $this->getHelper('question');
|
||||
|
||||
if (!$name = $input->getArgument('name')) {
|
||||
if (!$name = $input->getArgument('database')) {
|
||||
$name = $question->ask($input, $output, new Question('Database name: '));
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,18 @@
|
||||
namespace App\Console;
|
||||
|
||||
use App\Service\DatabaseService;
|
||||
use App\Service\Traits\SelectDatabaseQuestion;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[AsCommand('app:permissions:list')]
|
||||
class CreatePermissionCommand extends Command
|
||||
{
|
||||
use SelectDatabaseQuestion;
|
||||
|
||||
public function __construct(
|
||||
private readonly DatabaseService $db,
|
||||
)
|
||||
@ -18,6 +22,13 @@ class CreatePermissionCommand extends Command
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'User name');
|
||||
$this->addArgument('host', InputArgument::OPTIONAL, 'User host');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$dbs = $this->db->listDatabases();
|
||||
|
@ -24,7 +24,7 @@ class DeleteDatabaseCommand extends Command
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
|
@ -24,7 +24,7 @@ class PurgeDatabaseCommand extends Command
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
|
@ -28,7 +28,7 @@ class RestoreDatabaseCommand extends Command
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('database', InputArgument::OPTIONAL, 'Database name');
|
||||
$this->addArgument('file', InputArgument::OPTIONAL, 'Backup file name');
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ trait SelectDatabaseQuestion
|
||||
{
|
||||
$question = $this->getHelper('question');
|
||||
|
||||
if (!$name = $input->getArgument('name')) {
|
||||
if (!$name = $input->getArgument('database')) {
|
||||
$selectQuestion = new ChoiceQuestion('Database name: ', $this->db->listDatabases());
|
||||
$name = $question->ask($input, $output, $selectQuestion);
|
||||
}
|
||||
|
22
src/Service/Traits/SelectUserQuestion.php
Normal file
22
src/Service/Traits/SelectUserQuestion.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Traits;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
|
||||
trait SelectUserQuestion
|
||||
{
|
||||
private function getUserName(InputInterface $input, OutputInterface $output): string
|
||||
{
|
||||
$question = $this->getHelper('question');
|
||||
|
||||
if (!$name = $input->getArgument('name')) {
|
||||
$selectQuestion = new ChoiceQuestion('Database name: ', $this->db->listDatabases());
|
||||
$name = $question->ask($input, $output, $selectQuestion);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user