18
18
use Symfony \Component \Console \Attribute \AsCommand ;
19
19
use Symfony \Component \Console \Command \Command ;
20
20
use Symfony \Component \Console \Helper \QuestionHelper ;
21
+ use Symfony \Component \Console \Input \InputArgument ;
21
22
use Symfony \Component \Console \Input \InputInterface ;
22
23
use Symfony \Component \Console \Output \OutputInterface ;
23
24
use Symfony \Component \Console \Question \Question ;
@@ -43,16 +44,33 @@ public function __construct(
43
44
parent ::__construct ();
44
45
}
45
46
47
+ protected function configure (): void
48
+ {
49
+ $ this
50
+ ->addArgument ('email ' , InputArgument::OPTIONAL , 'Email address ' )
51
+ ->addArgument ('password ' , InputArgument::OPTIONAL , 'Password ' )
52
+ ;
53
+ }
54
+
46
55
protected function execute (InputInterface $ input , OutputInterface $ output ): int
47
56
{
48
57
$ style = new SymfonyStyle ($ input , $ output );
49
- $ username = $ this ->ask ('Please enter the email. ' , $ style , [new Email ()]);
50
58
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
+ }
56
74
57
75
$ user = new User ();
58
76
$ user ->setEmail ($ username );
0 commit comments