Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/Command/UserCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
Expand All @@ -43,16 +44,33 @@ public function __construct(
parent::__construct();
}

protected function configure(): void
{
$this
->addArgument('email', InputArgument::OPTIONAL, 'Email address')
->addArgument('password', InputArgument::OPTIONAL, 'Password')
;
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$style = new SymfonyStyle($input, $output);
$username = $this->ask('Please enter the email.', $style, [new Email()]);

$password = $this->askPassword(
(new Question('Please enter the user password.'))->setHidden(true)->setHiddenFallback(false),
$input,
$output
);
if (!empty($input->getArgument('email'))) {
$username = $input->getArgument('email');
} else {
$username = $this->ask('Please enter the email.', $style, [new Email()]);
}

if (!empty($input->getArgument('password'))) {
$password = $input->getArgument('password');
} else {
$password = $this->askPassword(
(new Question('Please enter the user password.'))->setHidden(true)->setHiddenFallback(false),
$input,
$output
);
}

$user = new User();
$user->setEmail($username);
Expand Down