/**
  * Builds an index of available commands. For each of them a Command object is
  * added to the commands array of this class.
  *
  * @return void
  */
 protected function buildCommandsIndex()
 {
     $availableCommands = $this->commandManager->getAvailableCommands();
     /** @var RunLevel $runLevel */
     $runLevel = ConsoleBootstrap::getInstance()->getEarlyInstance('Helhum\\Typo3Console\\Core\\Booting\\RunLevel');
     foreach ($availableCommands as $command) {
         if ($command->isInternal()) {
             continue;
         }
         $commandIdentifier = $command->getCommandIdentifier();
         $extensionKey = strstr($commandIdentifier, ':', TRUE);
         $commandControllerClassName = $command->getControllerClassName();
         $commandName = $command->getControllerCommandName();
         $shortCommandIdentifier = $this->commandManager->getShortestIdentifierForCommand($command);
         if ($runLevel->getMaximumAvailableRunLevel() === RunLevel::LEVEL_COMPILE && !$runLevel->isCommandAvailable($shortCommandIdentifier)) {
             continue;
         }
         $this->commandsByExtensionsAndControllers[$extensionKey][$commandControllerClassName][$commandName] = $command;
     }
 }
 /**
  * @param string $actionName
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\AmbiguousCommandIdentifierException
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchCommandException
  * @throws \RuntimeException
  */
 protected function dispatchAction($actionName)
 {
     $this->executeSilentConfigurationUpgradesIfNeeded();
     $arguments = $this->getCommandMethodArguments($actionName . 'Command');
     $command = $this->commandManager->getCommandByIdentifier('install:' . strtolower($actionName));
     $loopCounter = 0;
     do {
         $loopCounter++;
         $this->output->outputLine();
         $this->output->outputLine(sprintf('%s:', $command->getShortDescription()));
         $actionArguments = array();
         foreach ($command->getArgumentDefinitions() as $argumentDefinition) {
             $argument = $arguments->getArgument($argumentDefinition->getName());
             if (isset($this->givenRequestArguments[$argumentDefinition->getName()])) {
                 $actionArguments[$argumentDefinition->getName()] = $this->givenRequestArguments[$argumentDefinition->getName()];
             } else {
                 if (!$this->interactiveSetup) {
                     if ($argument->isRequired()) {
                         throw new \RuntimeException(sprintf('Argument "%s" is not set, but is required and user interaction has been disabled!', $argument->getName()), 1405273316);
                     } else {
                         continue;
                     }
                 }
                 $argumentValue = NULL;
                 do {
                     $argumentValue = $this->output->ask(sprintf('<comment>%s (%s):</comment> ', $argumentDefinition->getDescription(), $argument->isRequired() ? 'required' : sprintf('default: "%s"', $argument->getDefaultValue())));
                 } while ($argumentDefinition->isRequired() && $argumentValue === NULL);
                 $actionArguments[$argumentDefinition->getName()] = $argumentValue !== NULL ? $argumentValue : $argument->getDefaultValue();
             }
         }
         do {
             $messages = @unserialize($this->dispatcher->executeCommand('install:' . strtolower($actionName), $actionArguments));
         } while ($messages === 'REDIRECT');
         $messages = $messages ?: array();
         $this->outputMessages($messages);
         if ($loopCounter > 10) {
             throw new \RuntimeException('Tried to dispatch "' . $actionName . '" ' . $loopCounter . ' times.', 1405269518);
         }
     } while (!empty($messages));
 }