JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrgetDefinition()->addOption( option: new InputOption( name: strtolower(self::ALL), shortcut: 'a', mode: InputOption::VALUE_NONE, description: 'Check all Modules', ) ); $this->getDefinition()->addArgument( argument: new InputArgument( name: 'module', mode: InputArgument::IS_ARRAY, description: 'The name of module will be used.', ) ); if ($this instanceof ConfirmableCommand) { $this->configureConfirmable(); } } abstract public function executeAction($name); public function getInfo(): ?string { return null; } public function getConfirmableLabel(): ?string { return 'Warning'; } /** * Execute the console command. */ public function handle() { if ($this instanceof ConfirmableCommand) { if ($this->isProhibited() || ! $this->confirmToProceed($this->getConfirmableLabel(), fn () => true)) { return 1; } } if (! is_null($info = $this->getInfo())) { $this->components->info($info); } $modules = (array) $this->argument('module'); foreach ($modules as $module) { $this->executeAction($module); } } protected function promptForMissingArguments(InputInterface $input, OutputInterface $output): void { $modules = $this->hasOption('direction') ? array_keys($this->laravel['modules']->getOrdered($input->hasOption('direction'))) : array_keys($this->laravel['modules']->all()); if ($input->getOption(strtolower(self::ALL))) { $input->setArgument('module', $modules); return; } if (! empty($input->getArgument('module'))) { return; } $selected_item = multisearch( label: 'Select Modules', options: function (string $search_value) use ($modules) { return collect([ self::ALL, ...$modules, ])->when(strlen($search_value) > 0, function (Collection &$modules) use ($search_value) { return $modules->filter(fn ($item) => str_contains(strtolower($item), strtolower($search_value))); })->values()->toArray(); }, required: 'You must select at least one module', ); $input->setArgument( 'module', value: in_array(self::ALL, $selected_item) ? $modules : $selected_item ); } protected function getModuleModel($name) { return $name instanceof \Nwidart\Modules\Module ? $name : $this->laravel['modules']->findOrFail($name); } private function configureConfirmable(): void { $this->getDefinition() ->addOption( option: new InputOption( name: 'force', shortcut: null, mode: InputOption::VALUE_NONE, description: 'Force the operation to run without confirmation.', ) ); } }