Configure formatter with Elcodi specific style.

@param OutputInterface $output
489334
protected function configureFormatter(OutputInterface $output)
    {
        $formatter = $output->getFormatter();
        $formatter->setStyle('header', new OutputFormatterStyle('green'));
        $formatter->setStyle('failheader', new OutputFormatterStyle('red'));
        $formatter->setStyle('body', new OutputFormatterStyle('white'));
    }
589729
private function createMigrationsTable(OutputInterface $output = null)
    {
        if (!is_null($output)) {
            $output->writeln('<info>Creating migrations table</info>');
        }
        $m = new CreateMigrationsTable();
        $m->up();
    }
636475
protected function writeln(OutputInterface $output = null, $message)
    {
        if ($output instanceof OutputInterface) {
            $output->writeln($message);
        }
    }
488791
public function write(OutputInterface $output): void
    {
        $outputPath = $this->outputDir.'/'.$output->permalink()->relativeFilePath();
        if ($output->hasFileReference()) {
            $this->filesystem->copy($output->file(), $outputPath, true);
        } else {
            $this->filesystem->mkdir(dirname($outputPath));
            $this->filesystem->dumpFile($outputPath, $output->formattedContent());
        }
    }
92196
protected function formatOutput(OutputInterface $output, ResultIterator $info)
    {
        $output->writeln(
            sprintf(
                "Found <info>%d</info> relations in schema <info>'%s'</info>.",
                $info->count(),
                $this->schema
            )
        );
        $table = (new Table($output))
            ->setHeaders(['name', 'type', 'oid ', 'comment'])
            ;

        foreach ($info as $table_info) {
            $table->addRow([
                sprintf("<fg=yellow>%s</fg=yellow>", $table_info['name']),
                $table_info['type'],
                $table_info['oid'],
                wordwrap($table_info['comment'])
            ]);
        }

        $table->render();
    }
924386
public function innerCommand($output)
    {
        if ($this->output->isVeryVerbose()) {
            $this->write($output);
        }

        if (!$this->output->isVeryVerbose()) {
            $this->outputBuffer[] = $output;
        }
    }
506396
public function doMigrate(OutputInterface $output)
	{
		assert($this->_dispatcher);
		assert($this->_container);

		$this->_clearStatProperties();
		$call = self::$_call;

		$callPhpScript = function($event, $hash, $key, $script, $arguments) use ($call) {
			try
			{
				$errorReporting = error_reporting(E_ALL | E_STRICT);

				if (!$this->_evalCheckSyntax($script))
				{
					/** @noinspection PhpUndefinedMethodInspection */
					$message = sprintf(self::ERROR_WRONG_PHP_SYNTAX, $event->getMigrationName());
					/** @noinspection PhpUndefinedMethodInspection */
					throw new ErrorException($message, 0, E_PARSE, 'action N'.$event->getStep(), 0);
				}

				set_error_handler(function($severity, $message, $file = null, $line = null) {
					if (error_reporting() & $severity)
					{
						throw new ErrorException($message, 0, $severity, $file, $line);
					}
				}, E_ALL | E_STRICT);

				/** @var \Moro\Migration\Event\OnAskMigrationApply $event */
				$service = $this->_container->offsetGet($event->getServiceName());
				return $call($this->_container, $service, $arguments, trim($script), $hash, $this->getValidationKey().$key);
			}
			catch (Exception $exception)
			{
				/** @noinspection PhpUndefinedMethodInspection */
				$event->setException($exception);
				return -1;
			}
			finally
			{
				/** @noinspection PhpUndefinedVariableInspection */
				error_reporting($errorReporting);
				restore_error_handler();
			}
		};

		$this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create()->setOutput($output));

		try
		{
			$this->notify(self::STATE_FIRED);

			$modulesAndFiles = $this->_findModulesAndMigrationFiles();
			$migrations      = $this->_parseMigrationFiles($modulesAndFiles);

			$this->notify(self::STATE_FIND_MIGRATIONS);

			$actions         = $this->_askMigrationList($modulesAndFiles, $migrations);
			$actions         = $this->_sortMigrationsList($actions);

			$this->notify(self::STATE_MIGRATIONS_ASKED);

			if (empty($this->_statErrors))
			{
				$actions[0] && $this->_askMigrationRollback($actions[0], $callPhpScript);
				$actions[1] && $this->_askMigrationsApply($actions[1], $modulesAndFiles, $callPhpScript);
			}

			$this->notify(self::STATE_COMPLETE);
		}
		catch (Exception $exception)
		{
			$this->_printError($exception);
			$this->notify(self::STATE_COMPLETE);
		}
		finally
		{
			$this->_stateMigrationName = null;
			$this->_state = self::STATE_INITIALIZED;

			$this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create());
		}
	}
755824
protected function configureIO(InputInterface $input, OutputInterface $output)
    {
        if (true === $input->hasParameterOption(['--ansi'], true)) {
            $output->setDecorated(true);
        } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
            $output->setDecorated(false);
        }

        if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
            $input->setInteractive(false);
        } elseif (\function_exists('posix_isatty')) {
            $inputStream = null;

            if ($input instanceof StreamableInputInterface) {
                $inputStream = $input->getStream();
            }

            if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
                $input->setInteractive(false);
            }
        }

        switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
            case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break;
            case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break;
            case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break;
            case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break;
            default: $shellVerbosity = 0; break;
        }

        if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
            $shellVerbosity = -1;
        } else {
            if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
                $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
                $shellVerbosity = 3;
            } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
                $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
                $shellVerbosity = 2;
            } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
                $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
                $shellVerbosity = 1;
            }
        }

        if (-1 === $shellVerbosity) {
            $input->setInteractive(false);
        }

        putenv('SHELL_VERBOSITY='.$shellVerbosity);
        $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
        $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
    }
1271064
protected function formatOutput(OutputInterface $output, ConvertedResultIterator $fields_infos)
    {
        $output->writeln(sprintf("Relation <fg=cyan>%s.%s</fg=cyan>", $this->schema, $this->relation));
        $table = (new Table($output))
            ->setHeaders(['pk', 'name', 'type', 'default', 'notnull', 'comment'])
            ;

        foreach ($fields_infos as $info) {
            $table->addRow(
                [
                    $info['is_primary'] ? '<fg=cyan>*</fg=cyan>' : '',
                    sprintf("<fg=yellow>%s</fg=yellow>", $info['name']),
                    $this->formatType($info['type']),
                    $info['default'],
                    $info['is_notnull'] ? 'yes' : 'no',
                    wordwrap($info['comment']),
                ]
            );
        }

        $table->render();
    }
151723
public function initConfig(OutputInterface $output = null)
    {
        $log = function ($message) use ($output) {
            if ($output) {
                $output->writeln($message);
            }
        };

        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            throw new \RuntimeException('This feature is currently only supported on Linux and OSX (maybe). Please submit a PR to support it on windows.');
        }

        $configDir = $this->getConfigDir();
        $distDir = $this->getDistConfigDir();

        if (!$this->filesystem->exists($configDir)) {
            $log('<info>[+] Creating directory:</info> '.$configDir);
            $this->filesystem->mkdir($configDir);
        }

        $configFilenames = [
            'alias.yml',
            'phpcrsh.yml',
        ];

        foreach ($configFilenames as $configFilename) {
            $srcFile = $distDir.'/'.$configFilename;
            $destFile = $configDir.'/'.$configFilename;

            if (!$this->filesystem->exists($srcFile)) {
                throw new \Exception('Dist (source) file "'.$srcFile.'" does not exist.');
            }

            if ($this->filesystem->exists($destFile)) {
                $log(sprintf('<info>File</info> %s <info> already exists, not overwriting.', $destFile));

                return;
            }

            $this->filesystem->copy($srcFile, $destFile);
            $log('<info>[+] Creating file:</info> '.$destFile);
        }
    }
653599
protected function listSerializer(OutputInterface $output)
    {
        $table = new Table($output);

        /** @var SerializerManager $serializerManager */
        $serializerManager = $this->getContainer()->get(RegisterSerializerPass::MANAGER_SERVICE_ID);

        /** @var SerializerInterface $serializer */
        foreach ($serializerManager->getSerializers() as $serializer) {
            $table->addRow([
                $serializer->getId(),
                $serializer->getName(),
                $serializer->getExtension(),
                $serializer->getMimeType()
            ]);
        }

        $table
            ->setHeaders([
                'Id',
                'Name',
                'Extension',
                'MIME type'
            ])
            ->render()
        ;
    }
392799
protected function createTable(OutputInterface $output)
    {
        if (!class_exists('Symfony\Component\Console\Helper\Table')) {
            $table = new TableHelper(false);
        } else {
            $table = new Table($output);
        }

        return $table;
    }
28053
public static function format($output)
	{
		$output->addString('The profile log has the following format (');
		$output->addString('* indicates visible field', array('color'=>'blue'));
		$output->addLine('):');

		$i = 0;
		foreach (static::$fields as $field => $status)
		{
			if ($i != 0)
			{
				$output->addString(' ');
			}

			$output->addString('<');

			if ($i < 10)
			{
				$output->addString($i . ':');
			}

			if ($status)
			{
				$output->addString('*' . $field, array('color'=>'blue'));
			}
			else
			{
				$output->addString($field);
			}

			$output->addString('>');
			$i++;
		}

		$output->addSpacer()->addSpacer();
	}
231814
private function setPrefix(InputInterface $input, OutputInterface $output)
    {
        $this->prefix = $input->getOption('prefix');

        if ($this->prefix === null) {
            $this->prefix = $this->getTransifexConfigValue('/prefix');

            if ($this->prefix === null) {
                throw new \RuntimeException('Error: unable to determine transifex prefix.');
            }
            $this->writelnVerbose($output, sprintf('<info>automatically using prefix: %s</info>', $this->prefix));
        }

        $this->checkValidSlug($this->prefix);
    }
101557
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($input->getArgument('version') === null) {
            $version = $this->manager->getVersionFromProvider();
            $output->writeln(sprintf('Provider: <comment>%s</comment>', get_class($this->manager->getActiveProvider())));

            $formatter = $this->manager->getFormatter();
            if ($formatter instanceof FormatterInterface) {
                $output->writeln(sprintf('Formatter: <comment>%s</comment>', get_class($formatter)));
            } else {
                $output->writeln(sprintf('Formatter: <comment>%s</comment>', 'None'));
            }
        } else {
            $version = Version::fromString($input->getArgument('version'));
            $output->writeln(sprintf('Provider: <comment>%s</comment>', 'Symfony command'));
            $output->writeln(sprintf('Formatter: <comment>%s</comment>', 'Not available'));
        }

        $incrementMajor = (int) $input->getOption('major');
        if ($incrementMajor > 0) {
            for ($i = 0; $i < $incrementMajor; $i++) {
                $version = $version->withMajorIncremented();
            }
        }

        $incrementMinor = (int) $input->getOption('minor');
        if ($incrementMinor > 0) {
            for ($i = 0; $i < $incrementMinor; $i++) {
                $version = $version->withMinorIncremented();
            }
        }

        $incrementPatch = (int) $input->getOption('patch');
        if ($incrementPatch > 0) {
            for ($i = 0; $i < $incrementPatch; $i++) {
                $version = $version->withPatchIncremented();
            }
        }

        $preRelease = $input->getOption('prerelease');
        if (!empty($preRelease)) {
            if (in_array(null, $preRelease)) {
                $preRelease = array();
            }

            $version = $version->withPreRelease($preRelease);
        }

        $build = $input->getOption('build');
        if (!empty($build)) {
            if (in_array(null, $build)) {
                $build = array();
            }

            $version = $version->withBuild($build);
        }

        $currentVersion = $this->manager->getVersion();
        if ((string) $currentVersion == (string) $version) {
            $version = $version->withPatchIncremented();
        }

        $output->writeln(sprintf('Current version: <info>%s</info>', $currentVersion));
        $output->writeln(sprintf('New version: <info>%s</info>', $version));
        if ($input->getOption('dry-run')) {
            $output->writeln(sprintf('<question>%s</question>', 'Dry run, skipping version bump'));
        } else {
            $this->manager->writeVersion($version);
        }
    }
441539
protected function finishCommand(OutputInterface $output)
    {
        $event = $this->stopStopWatch('command');
        $this
            ->printMessage(
                $output,
                $this->getProjectHeader(),
                'Command finished in ' . $event->getDuration() . ' milliseconds'
            );
        $this->printMessage(
                $output,
                $this->getProjectHeader(),
                'Max memory used: ' . $event->getMemory() . ' bytes'
            );
        $output->writeln('');
    }
390058
public function publish(OutputInterface $output)
    {
        $callbacks = $this->getCallbacks();
        $publishDirectory = $this->getPublishDirectory();
        $fileSystem = $this->getFileSystem();

        if (empty($callbacks)) {
            throw new \Exception('No pages queued for publishing');
        }
        if ($fileSystem->directoryExists($publishDirectory)) {
            $fileSystem->recursiveRemoveDirectory($publishDirectory);
        }

        foreach ($callbacks as $path => $callback) {
            $pageSourcePath = $this->getPagePath($path);

            // Create a layout
            $layout = new Layout($this->getLayoutRenderer());
            $layout->setSource($this->getDefaultLayout());
            $layout->addAttributes($this->global);

            // Create a page
            $page = new Page($this->getPageRenderer());
            $page->setRawContent($fileSystem->getContents($pageSourcePath));
            $page->addAttributes($this->global);
            $page->setSource($path);

            // User callback
            call_user_func($callback, $page, $layout);

            // Render the page
            $page->setAttribute('url', $this->getPageUrl($page));
            $publishedContent = $page->render();
            $layoutSourcePath = $this->getLayoutPath($layout->getSource());

            if ($layout->isEnabled() && $fileSystem->fileExists($layoutSourcePath)) {
                $layout->setRawContent($fileSystem->getContents($layoutSourcePath));
                $publishedContent = $layout->render($page);
            }
            $pagePublishPath = $this->getPagePublishPath($page);
            $pagePublishDirectory = $this->getPagePublishDirectory($page);

            if (! $fileSystem->directoryExists($pagePublishDirectory)) {
                $fileSystem->createDirectory($pagePublishDirectory, 0755, true);
            }
            $fileSystem->putContents($pagePublishPath, $publishedContent);
            $output->writeln($this->publishMessage($pageSourcePath, $pagePublishPath));
            $this->pages[] = $page->getAttributes();
        }
        $fileSystem->copyDirectory($this->getAssetsDirectory(), $publishDirectory);
        $output->writeln($this->publishMessage($this->getAssetsDirectory(), $publishDirectory));

        return $this->pages;
    }