option('module') ?: $this->choice('Select the target module', $this->modules()); try { $files = $generator->generate((string) $module, $this->argument('model'), (bool) $this->option('force')); } catch (Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; } foreach ($files as $file) { $this->line("created {$file}"); } $this->warn('Register the generated controller routes in the target module Routes/web.php file.'); return self::SUCCESS; } private function modules(): array { return collect(glob(base_path('Modules/*/module.json')) ?: [])->map(fn (string $file) => basename(dirname($file)))->sort()->values()->all(); } }