Run the console application.

@param  \Symfony\Component\Console\Input\InputInterface  $input
@param  \Symfony\Component\Console\Output\OutputInterface  $output
@return int
549859
public function handle($input, $output = null)
	{
		try
		{
			$this->bootstrap();

			return $this->getArtisan()->run($input, $output);
		}
		catch (Exception $e)
		{
			$this->reportException($e);

			$this->renderException($output, $e);

			return 1;
		}
	}
1014081
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);

        $this->setOutput($output);
        $this->setVerbosity($output->getVerbosity());

        if ($input->getOption('child') && $output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
            $this->setVerbosity(self::VERBOSITY_CHILD);
        }

        $this->getContainer()->get('ez_migration_bundle.step_executed_listener.tracing')->setOutput($output);

        $migrationService = $this->getMigrationService();

        $force = $input->getOption('force');

        $toExecute = $this->buildMigrationsList($input->getOption('path'), $migrationService, $force);

        if (!count($toExecute)) {
            $output->writeln('<info>No migrations to execute</info>');
            return 0;
        }

        $this->printMigrationsList($toExecute, $input, $output);

        if (!$input->getOption('child')) {
            // ask user for confirmation to make changes
            if (!$this->askForConfirmation($input, $output)) {
                return 0;
            }
        }

        if ($input->getOption('separate-process')) {
            $builder = new ProcessBuilder();
            $executableFinder = new PhpExecutableFinder();
            if (false !== $php = $executableFinder->find()) {
                $builder->setPrefix($php);
            }
            $builderArgs = $this->createChildProcessArgs($input);
        }

        // For cli scripts, this means: do not die if anyone yanks out our stdout.
        if ($input->getOption('survive-disconnected-tty')) {
            ignore_user_abort(true);
        }

        // allow forcing handling of sigchild. Useful on eg. Debian and Ubuntu
        if ($input->getOption('force-sigchild-enabled')) {
            Process::forceSigchildEnabled(true);
        }

        $aborted = false;
        $executed = 0;
        $failed = 0;
        $skipped = 0;
        $total = count($toExecute);

        /** @var MigrationDefinition $migrationDefinition */
        foreach ($toExecute as $name => $migrationDefinition) {

            // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway
            if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
                $output->writeln("<comment>Skipping $name</comment>");
                $skipped++;
                continue;
            }

            $this->writeln("<info>Processing $name</info>");

            if ($input->getOption('separate-process')) {

                try {
                    $this->executeMigrationInSeparateProcess($migrationDefinition, $migrationService, $builder, $builderArgs);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;


                    $errorMessage = $e->getMessage();
                    // we probably have already echoed the error message while the subprocess was executing, avoid repeating it
                    if ($errorMessage != $this->subProcessErrorString) {
                        if ($e instanceof AfterMigrationExecutionException) {
                            $errorMessage = "Failure after migration end! Reason: " . $errorMessage;
                        } else {
                            $errorMessage = "Migration failed! Reason: " . $errorMessage;
                        }

                        $this->writeErrorln("\n<error>$errorMessage</error>");
                    }

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            } else {

                try {
                    $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;

                    $this->writeErrorln("\n<error>Migration failed! Reason: " . $e->getMessage() . "</error>");

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            }
        }

        $missed = $total - $executed - $failed - $skipped;

        if ($aborted) {
            if ($missed > 0) {
                $this->writeErrorln("\n<error>Migration execution aborted</error>");
            }
        } else {
            // NB: as per the Sf doc at https://symfony.com/doc/2.7/console/calling_commands.html, the 'cache:clear'
            // command should be run 'at the end', as they change some class definitions
            if ($input->getOption('clear-cache')) {
                $command = $this->getApplication()->find('cache:clear');
                $inputArray = new ArrayInput(array('command' => 'cache:clear'));
                $command->run($inputArray, $output);
            }
        }

        $this->writeln("\nExecuted $executed migrations, failed $failed, skipped $skipped" . ($missed ? ", missed $missed" : ''));

        $time = microtime(true) - $start;
        if ($input->getOption('separate-process')) {
            // in case of using subprocesses, we can not measure max memory used
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs</info>");
        } else {
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB</info>');
        }

        return $failed;
    }
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;
    }
1177449
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $this->_input = $input;
    $this->_output = $output;

    $params = array_values($input->getArguments());
    //Strip off the command name
    array_shift($params);

    //Call the execute command with $input and $output as the first args
    if(method_exists($this, 'executeCommand'))
    {
      array_unshift($params, $input, $output);
      return $this->executeCommand(...$params);
    }

    //Call the process method, without $input and $output
    if(method_exists($this, 'process'))
    {
      return $this->process(...$params);
    }

    throw new \RuntimeException(
      "Your command must contain one of the following methods:\n" .
      "process()\n" .
      'executeCommand(InputInterface $input, OutputInterface $output)' . "\n",
      500
    );
  }
980225
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setIO($input, $output);
        parent::doRun($input, $output);
    }
465431
public function doRun(InputInterface $input, OutputInterface $output)
    {
        if (true === $input->hasParameterOption(['--version', '-V'], true)) {
            $output->writeln($this->getLongVersion());

            return 0;
        }

        try {
            // Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
            $input->bind($this->getDefinition());
        } catch (ExceptionInterface $e) {
            // Errors must be ignored, full binding/validation happens later when the command is known.
        }

        $name = $this->getCommandName($input);
        if (true === $input->hasParameterOption(['--help', '-h'], true)) {
            if (!$name) {
                $name = 'help';
                $input = new ArrayInput(['command_name' => $this->defaultCommand]);
            } else {
                $this->wantHelps = true;
            }
        }

        if (!$name) {
            $name = $this->defaultCommand;
            $definition = $this->getDefinition();
            $definition->setArguments(array_merge(
                $definition->getArguments(),
                [
                    'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
                ]
            ));
        }

        try {
            $this->runningCommand = null;
            // the command name MUST be the first element of the input
            $command = $this->find($name);
        } catch (\Throwable $e) {
            if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
                if (null !== $this->dispatcher) {
                    $event = new ConsoleErrorEvent($input, $output, $e);
                    $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);

                    if (0 === $event->getExitCode()) {
                        return 0;
                    }

                    $e = $event->getError();
                }

                throw $e;
            }

            $alternative = $alternatives[0];

            $style = new SymfonyStyle($input, $output);
            $style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
            if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
                if (null !== $this->dispatcher) {
                    $event = new ConsoleErrorEvent($input, $output, $e);
                    $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);

                    return $event->getExitCode();
                }

                return 1;
            }

            $command = $this->find($alternative);
        }

        $this->runningCommand = $command;
        $exitCode = $this->doRunCommand($command, $input, $output);
        $this->runningCommand = null;

        return $exitCode;
    }
850737
protected function execute(InputInterface $input, OutputInterface $output)
    {
        return $this->getRunner($input, $output)->run() ? 0 : -1;
    }
594086
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;

        try {
            return $this->fire();
        } catch (DomainException $e) {
            return 1;
        } catch (Exception $e) {
            $this->error($e->getMessage());
            $this->error('Abort!');
        }

        return;
    }
404353
public function doRun(InputInterface $input, OutputInterface $output)
  {
    $this->configure($this->getContext()->config());
    return parent::doRun($input, $output);
  }
1225865
public function doRun(InputInterface $input, OutputInterface $output)
    {

        $ioFactory = ConsoleIOFactory::buildDefault($input, $output, $this->getHelperSet());
        $this->io = $ioFactory->get();

        return parent::doRun($input, $output);
    }
239355
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->requireConfig();

        $output->writeln('Starting <fg=blue>Magallanes</>');
        $output->writeln('');

        $output->writeln(sprintf('<comment>%s</comment>', var_export($this->runtime->getConfiguration(), true)));

        $output->writeln('');
        $output->writeln('Finished <fg=blue>Magallanes</>');

        return 0;
    }
608343
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (empty($path = $input->getArgument('path'))) {
            $this->render($input, $output);
        } else {
            $this->test($input->getArgument('method'), $path, $input, $output);
        }

        return 0;
    }
53704
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->before($input, $output);
        $this->runTransient($input, $output);
        $this->after($input, $output);
    }
653255
protected function runCommand(InputInterface $input, OutputInterface $output)
    {
        $repository = $this->getRepository($input, $output);
        $file = $input->getArgument('file');

        self::exportToFile(
            $file,
            $output,
            function (Query $query) use ($repository) {
                return $repository->query($query);
            }
        );
    }
51852
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $this->createOutput($input, $output);

        $this->getFacade()->runInstall(
            $this->getCommandLineArgumentContainer(),
            $this->getCommandLineOptionContainer(),
            $this->output
        );

        return 0;
    }
1151786
protected function execute(InputInterface $input, OutputInterface $output)
    {
        try
        {
            if (method_exists($this, 'start'))
            {
                $this->start();
            }
            else
            {
                throw new \RuntimeException('Command is not set correctly.');
            }
        }
        catch (\Exception $e)
        {
            $this->error($e->getMessage());
        }
    }
1201620
protected function execute(InputInterface $input, OutputInterface $output) : int
    {
        $body = $input->getArgument('body');
        $json = json_decode($input->getArgument('body'), true);
        if (json_last_error() !== 0) {
            $body = $json;
        }

        $queue = self::queue($input->getOption('queue'));
        $queue->publish($body);

        return 0;
    }