1111
1212namespace MageGen ;
1313
14+ use MageGen \Autocomplete \ModuleAutocomplete ;
1415use MageGen \Generator \DiGenerator ;
1516use MageGen \Writer \ClassFile ;
1617use Nette \PhpGenerator \ClassType ;
@@ -54,9 +55,10 @@ public function __construct(Environment $twig, string $name = null)
5455 protected function configure (): void
5556 {
5657 parent ::configure ();
58+ $ this ->addArgument ('module ' , InputArgument::OPTIONAL , 'Module name ' );
5759 $ this ->addArgument ('subject ' , InputArgument::OPTIONAL , 'Plugin subject / target ' );
5860 $ this ->addArgument ('method ' , InputArgument::OPTIONAL , 'Subject method ' );
59- $ this ->addArgument ('class ' , InputArgument::OPTIONAL , 'Plugin class name ' );
61+ $ this ->addArgument ('class ' , InputArgument::OPTIONAL , 'Plugin class name relative to module Plugin/ ' );
6062 $ this ->addArgument ('type ' , InputArgument::OPTIONAL , "before, around, after " );
6163 $ this ->addArgument (
6264 'area ' ,
@@ -74,6 +76,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7476
7577 $ io = new SymfonyStyle ($ input , $ output );
7678
79+ $ module = $ input ->getArgument ('module ' );
80+ if (!$ module ) {
81+ $ module = $ io ->askQuestion (
82+ (new Question ('Module ' ))->setAutocompleterValues (
83+ (new ModuleAutocomplete ())->getAutocompleteValues (
84+ $ input ->getOption ('magepath ' )
85+ )
86+ )
87+ );
88+ }
89+
7790 $ subject = $ input ->getArgument ('subject ' );
7891 if (!$ subject ) {
7992 $ subject = $ io ->askQuestion (
@@ -86,11 +99,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8699 new Question ('method ' )
87100 );
88101 }
89- $ classFqn = $ input ->getArgument ('class ' );
90- if (!$ classFqn ) {
91- $ classFqn = $ io ->askQuestion (new Question ('Class ' ));
102+ $ className = $ input ->getArgument ('class ' );
103+ if (!$ className ) {
104+ $ className = $ io ->askQuestion (new Question ('Class ' ));
92105 }
93106
107+ $ classFqn = implode (
108+ '\\' ,
109+ [
110+ str_replace ('_ ' , '\\' , $ module ),
111+ 'Plugin ' ,
112+ $ className ,
113+ ]
114+ );
115+
94116 $ type = $ input ->getArgument ('type ' );
95117 if (!$ type ) {
96118 $ type = $ io ->choice ('Type ' , ['before ' , 'around ' , 'after ' ]);
0 commit comments