/** * Display index of actions * * @param string $type * * @return void */ protected function displayActionIndex($type = 'Check') { $this->messageBus->headerMessage('Avaliable ' . $type . 's:', 'info'); $type = strtolower($type); if ($this->availableActions === array()) { $this->availableActions = $this->commandManager->getAvailableCommands(); } $colorizedIdentifierLength = $this->getMaximumIdentifierLength($this->availableActions[$type], TRUE); $identifierLength = $this->getMaximumIdentifierLength($this->availableActions[$type]); $this->messageBus->message(vsprintf(' %-' . $identifierLength . 's %s', array('Identifier', 'Description'))); $this->messageBus->horizontalLine(); /** @var Tx_Smoothmigration_Checks_AbstractCheckDefinition $command */ $counter = 1; foreach ($this->availableActions[$type] as $command) { $this->autoCompleteValues['actions'][] = $command->getIdentifier(); $description = wordwrap($command->getShortDescription(), TERMINAL_WIDTH - $identifierLength - 7, PHP_EOL . str_repeat(' ', $identifierLength + 7), TRUE); $shortCommandIdentifier = $command->getIdentifier(); $this->messageBus->message(vsprintf('%2s) %-' . $colorizedIdentifierLength . 's %s', array($counter, $this->messageBus->successString($shortCommandIdentifier), $description))); $counter++; } $this->messageBus->message(); if ($this->isInInteractiveMode) { $this->messageBus->setCompletions(array('actions' => $this->autoCompleteValues['actions'], 'extensions' => Tx_Smoothmigration_Utility_ExtensionUtility::getLoadedExtensionsFiltered())); $actions = $this->autoCompleteValues['actions'][$type]; $this->messageBus->usage(); $response = $this->messageBus->prompt(); $this->messageBus->message(); list($code, $extension) = explode(' ', $response); if (array_key_exists($code, $actions)) { readline_add_history($response); $method = $type . 'Command'; $this->{$method}($actions[$code], $extension); } elseif (in_array($code, $actions)) { readline_add_history($response); $method = $type . 'Command'; $this->{$method}($code, $extension); } elseif ($code == -1) { $this->interactiveCommand(); } else { $this->messageBus->errorMessage('Uknown comand: ' . $code); $this->interactiveCommand(); } } else { $this->messageBus->message('Usage: ./cli_dispatch.phpsh extbase smoothmigration:' . $type . ' <Identifier> [extensionName]'); } $this->messageBus->message(); }
/** * Migrate * * @param string $migrationTaskKey * @param string $extensionKey * @param boolean $experimental When TRUE, try to process experimental * migrations as well * @return void */ private function migrate($migrationTaskKey, $extensionKey = '', $experimental) { $migrationTask = NULL; /** @var Tx_Smoothmigration_Service_Migration_Registry $registry */ $registry = Tx_Smoothmigration_Service_Migration_Registry::getInstance(); if (!empty($migrationTaskKey)) { $migrationTask = $registry->getActiveMigrationByCliKey($migrationTaskKey); } if ($migrationTask === NULL) { $this->messageBus->message('Please choose a migration to execute.' . LF . LF . 'Possible options are:' . LF); $this->messageBus->message($this->getMigrations()); return; } /** @var Tx_Smoothmigration_Migrations_AbstractMigrationProcessor $processor */ $processor = $migrationTask->getProcessor(); $processor->setMessageService($this->messageBus); $processor->setExperimental($experimental); $processor->setExtensionKey($extensionKey); $processor->execute(); }