1818use Symfony \Component \Console \Attribute \AsCommand ;
1919use Symfony \Component \Console \Command \Command ;
2020use Symfony \Component \Console \Helper \QuestionHelper ;
21+ use Symfony \Component \Console \Input \InputArgument ;
2122use Symfony \Component \Console \Input \InputInterface ;
2223use Symfony \Component \Console \Output \OutputInterface ;
2324use 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