Skip to content

Commit c6ce9a6

Browse files
Merge pull request #59 from cleverage/57
#57 add arguments to pass username and password to cleverage:ui-process:user-create
2 parents dbd834f + 5929a5e commit c6ce9a6

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/Command/UserCreateCommand.php

+24-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Attribute\AsCommand;
1919
use Symfony\Component\Console\Command\Command;
2020
use Symfony\Component\Console\Helper\QuestionHelper;
21+
use Symfony\Component\Console\Input\InputArgument;
2122
use Symfony\Component\Console\Input\InputInterface;
2223
use Symfony\Component\Console\Output\OutputInterface;
2324
use Symfony\Component\Console\Question\Question;
@@ -43,16 +44,33 @@ public function __construct(
4344
parent::__construct();
4445
}
4546

47+
protected function configure(): void
48+
{
49+
$this
50+
->addArgument('email', InputArgument::OPTIONAL, 'Email address')
51+
->addArgument('password', InputArgument::OPTIONAL, 'Password')
52+
;
53+
}
54+
4655
protected function execute(InputInterface $input, OutputInterface $output): int
4756
{
4857
$style = new SymfonyStyle($input, $output);
49-
$username = $this->ask('Please enter the email.', $style, [new Email()]);
5058

51-
$password = $this->askPassword(
52-
(new Question('Please enter the user password.'))->setHidden(true)->setHiddenFallback(false),
53-
$input,
54-
$output
55-
);
59+
if (!empty($input->getArgument('email'))) {
60+
$username = $input->getArgument('email');
61+
} else {
62+
$username = $this->ask('Please enter the email.', $style, [new Email()]);
63+
}
64+
65+
if (!empty($input->getArgument('password'))) {
66+
$password = $input->getArgument('password');
67+
} else {
68+
$password = $this->askPassword(
69+
(new Question('Please enter the user password.'))->setHidden(true)->setHiddenFallback(false),
70+
$input,
71+
$output
72+
);
73+
}
5674

5775
$user = new User();
5876
$user->setEmail($username);

0 commit comments

Comments
 (0)