Get progress.

@param InputInterface $input
@param OutputInterface $output

@return Decorator
964378
protected function getProgress(InputInterface $input, OutputInterface $output)
    {
        if ($input->getOption('no-progress')) {
            $output = new NullOutput();
        }

        // export progress only for one storage
        if (!$input->getArgument('storage')) {
            $input->setOption('export', null);
        }

        if ($export_file = $input->getOption('export')) {
            // progress is redirected to the export file
            $input->setOption('no-progress', true);
            $progress = new Export($this->getHelperSet()->get('progress'), new NullOutput(), $export_file);
        } else {
            $progress = new PresetOutput($this->getHelperSet()->get('progress'), $output);
        }

        $progress->setBarCharacter('<comment>=</comment>');

        return $progress;
    }
1135012
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $this->io = new StratumStyle($input, $output);

    $command = $this->getApplication()->find('constants');
    $ret     = $command->execute($input, $output);
    if ($ret!=0) return $ret;

    $command = $this->getApplication()->find('loader');
    $ret     = $command->execute($input, $output);
    if ($ret!=0) return $ret;

    $command = $this->getApplication()->find('wrapper');
    $ret     = $command->execute($input, $output);

    $this->io->writeln('');

    return $ret;
  }
77779
private function runExternal(InputInterface $input, OutputInterface $output)
    {
        $wait = (int) $input->getOption('wait');
        $wait = $wait * 1000; // convert from milli to micro

        $cwd = realpath($this->getContainer()->get('kernel')->getRootDir() . '/..');

        while (true) {
            $process = new Process(
                'php app/console channel:export -e ' . $input->getOption('env'),
                $cwd,
                null,
                null,
                null
            );
            $process->run(function ($type, $buffer) use ($output) {
                $output->write($buffer, false, OutputInterface::OUTPUT_RAW);
            });

            if (!$process->isSuccessful()) {
                break; // terminate when there is a error
            }

            if (!$input->getOption('daemon')) {
                if (!$this->exporter->getQueue()->count()) {
                    break;
                }
            }

            usleep($wait);
        }

        return 0;
    }
234391
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $pipeLine = $this->pipeline;
        $pipeLine($input->getOptions());

        return 0;
    }
1131188
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Looking for updates...');

        $manager         = $this->createManager($output);
        $version         = $input->getArgument('version')
            ? $input->getArgument('version')
            : $this->getApplication()->getVersion();
        $allowMajor      = $input->getOption('major');
        $allowPreRelease = $input->getOption('pre');

        if (strpos($version, 'v') === 0) {
            // strip v tag from phar version for self-update
            $version = str_replace('v', '', $version);
        }

        $this->updateCurrentVersion($manager, $version, $allowMajor, $allowPreRelease, $output);

        return 0;
    }
1259806
protected function execute(InputInterface $input, OutputInterface $output)
    {
        // {{
        $this->title('配置信息');
        // }}

        $this->treeView(Config::get(''));
        $this->newLine();

        return 0;
    }
179708
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        $logger = LoggerHelper::createDefaultLogger($output);

        /** @var string $cacheOption */
        $cacheOption = $input->getOption('cache');
        $fileCache = new FilesystemCache($cacheOption);
        $cache = new SimpleCacheAdapter($fileCache);

        $logger->info('initializing converting process');

        $browscap = new BrowscapUpdater($cache, $logger);

        $logger->info('started converting local file');

        /** @var string $file */
        $file = $input->getArgument('file');
        if (! $file) {
            $file = $this->defaultIniFile;
        }

        $output->writeln(sprintf('converting file %s', $file));

        try {
            $browscap->convertFile($file);
        } catch (Exception\FileNameMissingException $e) {
            $logger->debug($e);

            return 6;
        } catch (Exception\FileNotFoundException $e) {
            $logger->debug($e);

            return 7;
        } catch (Exception\ErrorReadingFileException $e) {
            $logger->debug($e);

            return 8;
        }

        $logger->info('finished converting local file');

        return 0;
    }
1149482
protected function getProgressBar(InputInterface $input)
    {
        $progress = parent::getProgressBar($input);
        if (!$progress) {
            return null;
        }

        /** @var Dispatcher $eventDispatcher */
        $eventDispatcher = $this->getService('event_dispatcher');
        $eventDispatcher->addListener(
            'transformer.transformation.post',
            function () use ($progress) {
                $progress->advance();
            }
        );

        return $progress;
    }
370565
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        $input  = $input ?: new ArgvInput();
        $output = $output ?: new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, null, $this->formatter());

        return parent::run($input, $output);
    }
294624
public function run(InputInterface $input, OutputInterface $output): int
    {
        return $this->console->run($input, $output);
    }
918941
private function runInternal(InputInterface $input, OutputInterface $output)
    {
        try {
            $this->exporter->execute();
        } catch (Exception $e) {
            $output->writeln("Aborting: " . $e->getMessage());

            return 1;
        }

        return 0;
    }
660989
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $iterationCount = (int)$input->getOption('iteration-count');

        $locationsCount = $this->repository->sudo(
            function (Repository $repository) {
                return $repository->getLocationService()->getAllLocationsCount();
            }
        );

        $helper = $this->getHelper('question');
        $question = new ConfirmationQuestion(
            sprintf(
                "<info>Found %d Locations.</info>\n%s\n<info>Do you want to proceed? [y/N] </info>",
                $locationsCount,
                self::BEFORE_RUNNING_HINTS
            ),
            false
        );
        if (!$helper->ask($input, $output, $question)) {
            return;
        }

        $output->writeln('Regenerating System URL aliases...');

        $progressBar = $this->getProgressBar($locationsCount, $output);
        $progressBar->start();

        for ($offset = 0; $offset <= $locationsCount; $offset += $iterationCount) {
            gc_disable();
            $locations = $this->repository->sudo(
                function (Repository $repository) use ($offset, $iterationCount) {
                    return $repository->getLocationService()->loadAllLocations($offset, $iterationCount);
                }
            );
            $this->processLocations($locations, $progressBar);
            gc_enable();
        }
        $progressBar->finish();
        $output->writeln('');
        $output->writeln('<info>Done.</info>');

        $output->writeln('<info>Cleaning up corrupted URL aliases...</info>');
        $corruptedAliasesCount = $this->repository->sudo(
            function (Repository $repository) {
                return $repository->getURLAliasService()->deleteCorruptedUrlAliases();
            }
        );
        $output->writeln("<info>Done. Deleted {$corruptedAliasesCount} entries.</info>");
        $output->writeln('<comment>Make sure to clear HTTP cache afterwards.</comment>');
    }
1264419
public function execute(InputInterface $input, OutputInterface $output)
    {
        $filesystem = new Filesystem();
        $discouraged = RootDirectories::getDiscouraged();
        $found = [];

        foreach ($discouraged as $directory => $comment) {
            if ($filesystem->exists($directory) && is_dir($directory)) {
                $found[] = [$directory, $comment];
            }
        }

        if (count($found) == 0) {
            $output->writeln('<fg=green>No issues found.</fg=green>');

            return 0;
        }

        $output->writeln('The following issues where found:');

        $table = new Table($output);

        $table->setHeaders(['Directory', 'Comment']);
        $table->setRows($found);
        $table->render();

        return 1;
    }
1295577
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        $user = $this->findUser($output, $username);
        if (null === $user) {
            return 1;
        }

        $user->setSuperAdmin(!$input->getOption('demote'));
        $this->userManager->save($user);

        if ($user->isSuperAdmin()) {
            $message = $this->translator->trans(
                'user.promoted',
                ['%username%' => $username],
                'security'
            );
        } else {
            $message = $this->translator->trans(
                'user.demoted',
                ['%username%' => $username],
                'security'
            );
        }
        $output->writeln("<info>{$message}</info>");

        return 0;
    }
1132827
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        parent::execute($input, $output);

        $this->queue->consume(function (Message $message) {
            return $this->consumeCallback($message);
        });

        return $this->sendExitCode();
    }
1328464
protected function execute(
        InputInterface $input,
        OutputInterface $output
    ): int {
        $composer   = $this->getComposer(true);
        $guard      = $this->guardFactory->create();
        $violations = $guard->determineViolations($composer);
        $exporter   = $this->exporterFactory->create($input, $output);

        $exporter->export($violations);

        return count($violations) > 0
            ? static::EXIT_VIOLATIONS
            : static::EXIT_NO_VIOLATIONS;
    }
130126
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);

        $days = $input->getArgument('days');
        $entries = $this
            ->metricLoader
            ->loadEntriesFromLastDays($days);

        $nbEntries = count($entries);
        $this->printMessage(
            $output,
            'Metric',
            'Added ' . $nbEntries . ' entries from last ' . $days . ' days'
        );

        $this->finishCommand($output);
    }