Implement create permission command

This commit is contained in:
Tim
2024-09-24 00:42:03 +02:00
parent 153f04ccd7
commit 9887282b62
7 changed files with 68 additions and 53 deletions

View File

@ -22,7 +22,7 @@ class CreateUserCommand extends Command
public function configure(): void
{
$this->addArgument('name', InputArgument::OPTIONAL, 'User name');
$this->addArgument('user', InputArgument::OPTIONAL, 'User name');
$this->addArgument('password', InputArgument::OPTIONAL, 'User password');
$this->addArgument('host', InputArgument::OPTIONAL, 'User host');
}
@ -31,12 +31,12 @@ class CreateUserCommand extends Command
{
$question = $this->getHelper('question');
$name = $input->getArgument('name');
$user = $input->getArgument('user');
$password = $input->getArgument('password');
$host = $input->getArgument('host');
if (!$name) {
$name = $question->ask($input, $output, new Question('User name: '));
if (!$user) {
$user = $question->ask($input, $output, new Question('User name: '));
}
if (!$password) {
$passwordQuestion = new Question('User password: ');
@ -44,9 +44,9 @@ class CreateUserCommand extends Command
$password = $question->ask($input, $output, $passwordQuestion);
}
$this->db->createUser($name, $password, $host);
$this->db->createUser($user, $password, $host);
$output->writeln(sprintf('User "%s" successfully created', $name));
$output->writeln(sprintf('User "%s" successfully created', $user));
return Command::SUCCESS;
}