/** * @return string */ public function generate() { $res = ''; foreach ($this->titles as $title) { $res .= CLIHelper::EOL . CLIHelper::writeColoredLn($title, CLIHelper::COLOR_LIGHT_PURPLE) . CLIHelper::EOL; } if ($this->usages) { $this->addInfoBlock('USAGE', $this->usages); } if ($this->descriptions) { $this->addInfoBlock('DESCRIPTION', $this->descriptions); } if ($this->actions) { $this->addInfoBlock('ACTIONS', $this->buildActions()); } if ($this->examples) { $this->addInfoBlock('EXAMPLES', $this->examples); } foreach ($this->infoBlocks as $infoBlockTitle => $infoBlockContents) { $res .= CLIHelper::writeColoredLn($infoBlockTitle, CLIHelper::COLOR_PURPLE); $res .= implode(CLIHelper::EOL, array_map(function ($v) { return CLIHelper::TAB . $v; }, $infoBlockContents)); $res .= CLIHelper::EOL . CLIHelper::EOL; } return $res; }
public function actionList(array $args = []) { $what = reset($args); switch ($what) { default: CLIHelper::outputLn(CLIHelper::writeInfoLn('Usage: yiic migraptor list [list_type]')); $data = ['connections', 'types']; $what = 'lists'; break; case 'connections': $data = array_keys($this->getConnections()); break; case 'types': $data = []; foreach ($this->_migrationTypes as $migrationTypeKey => $migrationType) { $migrationTypeDescription = isset($migrationType['description']) ? $migrationType['description'] : ''; $migrationTypeBehavior = isset($migrationType['behavior']) ? $migrationType['behavior'] : ''; $migrationTypeExecuteAlways = isset($migrationType['execute_always']) ? (bool) $migrationType['execute_always'] : false; $migrationTypeIsDefault = isset($this->_migrationTypesDefault[$migrationTypeKey]); $data[] = $migrationTypeKey . CLIHelper::EOL . CLIHelper::TAB . CLIHelper::TAB . ($migrationTypeIsDefault ? CLIHelper::writeColored('{default} ', CLIHelper::COLOR_LIGHT_GREEN) : '') . '[' . $migrationTypeBehavior . '] (' . ($migrationTypeExecuteAlways ? 'always' : 'not always') . ') ' . $migrationTypeDescription; } break; } CLIHelper::outputLn(CLIHelper::writeInfo('Available ' . $what . ':')); foreach ($data as $item) { CLIHelper::outputLn(CLIHelper::TAB . '- ' . $item); } }