*/ protected function promptForMissingArgumentsUsing(): array { return [ 'section' => fn () => select('Article section', $this->listSections()), ]; } /** * Return either an instance of the bundle creator or form specifications */ protected function getBundleCreator(string $section, ?array $data = []): array|CreatesBundle { return app()->make('bundleCreator.factory')->getBundleCreatorFor($section, $data); } /** * Execute the console command. */ public function handle() { $section = $this->argument('section'); $data = []; $creator = $this->getBundleCreator($section); while (!$creator->canCreateBundle()) { $specs = $creator->formSpecs(); foreach ($specs as $key => $func) { $data[$key] = $func(); } $creator = $this->getBundleCreator($section, $data); } $path = $creator->createBundle(); $this->info('Bundle created successfully!'); $this->line($path); } /** * List available sections as options for a select input */ private function listSections() { $sections = config('sections'); $options = []; foreach ($sections as $name => $data) { $options[$name] = $data['title']; } return $options; } }