/**
  * Print a list of all migrations of a specific module, along with their current status
  *
  * @param string $moduleName [optional] The target module (vendor-name/package-name syntax).
  *                           If not specified, the user will be prompted for it
  * @param array  $options
  * @option $format|f      The output format. Allowed values: 'json|text'. If not specified, text is output.
  * @return int Status code
  */
 function migrateStatus($moduleName = null, $options = ['format|f' => 'text'])
 {
     $this->setupModule($moduleName);
     $migrations = $this->migrationsAPI->status();
     $formattedMig = map($migrations, function ($mig) {
         return [$mig[Migration::date], Migration::toDateStr($mig[Migration::date]), $mig[Migration::name], $mig[Migration::status]];
     });
     switch (get($options, 'format', 'text')) {
         case 'json':
             $this->io->writeln(json_encode(array_values($migrations), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
             break;
         case 'text':
             if ($formattedMig) {
                 $this->io->table(['Version', 'Date', 'Name', 'Status'], $formattedMig, [15, 20, 40, 8]);
             } else {
                 $this->io->cancel('The module has no migrations');
             }
             break;
         default:
             $this->io->error('Invalid format');
     }
     return 0;
 }
 /**
  * Validate the given module name or ask the user to select a module from a list of installed modules.
  *
  * <p>This method is available to console tasks only.
  *
  * @param string   $moduleName     A variable reference. If empty, it will be set to the selected module name.
  * @param callable $filter         Display only modules that match a filtering condition.
  *                                 <p>Callback syntax: <code>function (ModuleInfo $module):bool</code>
  * @param bool     $suppressErrors Do not abort execution with an error message if the module name is not valid.
  * @return bool false if the specified module name does not match an installed module
  * @internal param bool $onlyEnabled Display only modules that are enabled.
  */
 function selectModule(&$moduleName, callable $filter = null, $suppressErrors = false)
 {
     if ($moduleName) {
         if (!ModulesRegistry::validateModuleName($moduleName)) {
             if ($suppressErrors) {
                 return false;
             }
             $this->io->error("Invalid module name {$moduleName}. Correct syntax: vendor-name/product-name");
         }
         if (!$this->registry->isInstalled($moduleName)) {
             if ($suppressErrors) {
                 return false;
             }
             $this->io->error("Module {$moduleName} is not installed");
         }
         if ($filter && !$filter($this->registry->getModule($moduleName))) {
             if ($suppressErrors) {
                 return false;
             }
             $this->io->error("Module {$moduleName} can't be renamed");
         }
     } else {
         $modules = $this->registry->onlyPrivateOrPlugins()->only($filter)->getModuleNames();
         if ($modules) {
             $i = $this->io->menu("Select a module:", $modules);
             if ($i < 0) {
                 $this->io->cancel();
             }
             $moduleName = $modules[$i];
         } else {
             if ($suppressErrors) {
                 return false;
             }
             $this->io->error("No modules are available");
         }
     }
     return true;
 }
 private function customizeColors()
 {
     $this->io->setColor('title', new OutputFormatterStyle('magenta'))->setColor('question', new OutputFormatterStyle('cyan'))->setColor('red', new OutputFormatterStyle('red'))->setColor('warning', new OutputFormatterStyle('black', 'yellow'))->setColor('error-info', new OutputFormatterStyle('green', 'red'))->setColor('kbd', new OutputFormatterStyle('green'));
 }