From 8f13ae921c2b7e1f5a0bc1c87d161880591a3b73 Mon Sep 17 00:00:00 2001 From: xmarchegay Date: Thu, 3 Apr 2025 19:43:33 +0200 Subject: [PATCH 1/2] #57 add arguments to pass username and password to cleverage:ui-process:user-create --- src/Command/UserCreateCommand.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Command/UserCreateCommand.php b/src/Command/UserCreateCommand.php index 806cc0c..9840809 100644 --- a/src/Command/UserCreateCommand.php +++ b/src/Command/UserCreateCommand.php @@ -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; @@ -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 ($input->getArgument('email')) { + $username = $input->getArgument('email'); + } else { + $username = $this->ask('Please enter the email.', $style, [new Email()]); + } + + if ($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); From 5929a5e76a6cf03107c1a9b7ccdb8066d8666551 Mon Sep 17 00:00:00 2001 From: xmarchegay Date: Fri, 4 Apr 2025 13:36:30 +0200 Subject: [PATCH 2/2] #57 make sure the arguments are not empty --- src/Command/UserCreateCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Command/UserCreateCommand.php b/src/Command/UserCreateCommand.php index 9840809..55b323b 100644 --- a/src/Command/UserCreateCommand.php +++ b/src/Command/UserCreateCommand.php @@ -56,13 +56,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int { $style = new SymfonyStyle($input, $output); - if ($input->getArgument('email')) { + if (!empty($input->getArgument('email'))) { $username = $input->getArgument('email'); } else { $username = $this->ask('Please enter the email.', $style, [new Email()]); } - if ($input->getArgument('password')) { + if (!empty($input->getArgument('password'))) { $password = $input->getArgument('password'); } else { $password = $this->askPassword(