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); } /** * Prompt for missing input arguments using the returned questions. * * @return array */ 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 BundleCreator::getBundleCreatorFor($section, $data); } /** * List available sections as options for a select input */ private function listSections() { $sections = Bundle::findBundles(Storage::disk(env('CONTENT_DISK')), '/'); $options = []; foreach ($sections as $bundle) { $options[basename($bundle->getPath())] = $bundle->getArticleTitle(); } return $options; } }