Returns manager instance or exit with status code 1 on failure.

@param OutputInterface $output

@return \Herrera\Phar\Update\Manager
14956
private function createManager(OutputInterface $output)
    {
        try {
            return new Manager(Manifest::loadFile(self::MANIFEST_FILE));
        } catch (FileException $e) {
            $output->writeln('<error>Unable to search for updates.</error>');

            exit(1);
        }
    }
319055
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        $this->setAutoExit(false);
        $this->getContainer()->boot();
        $this->setDispatcher($this->getContainer()['dispatcher']);
        $this->getContainer()['dispatcher']->dispatch(ConsoleEvents::INIT, new ConsoleEvent($this));
        $this->getContainer()->flush();
        $exitCode = parent::run($input, $output);
        $this->getContainer()->terminate(new Request(), new Response());

        return $exitCode;
    }
87164
private function writeToOutputNow($output)
    {
        if ($this->sendHttpCode() && \Whoops\Util\Misc::canSendHeaders()) {
            $this->system->setHttpResponseCode(
                $this->sendHttpCode()
            );
        }

        echo $output;

        return $this;
    }
37911
public function update(OutputStyle $output): void
    {
        $result = $this->updater->update();

        if ($result) {
            $output->success(sprintf('Updated from version %s to %s.', $this->updater->getOldVersion(),
                $this->updater->getNewVersion()));
            exit(0);
        } elseif (! $this->updater->getNewVersion()) {
            $output->success('There are no stable versions available.');
        } else {
            $output->success('You have the latest version installed.');
        }
    }
615406
public static function getInstance(OutputInterface $output = null): ConsoleLogger
    {
        if (!isset(self::$logger)) {
            self::$logger = new ConsoleLogger($output);
        }
        return self::$logger;
    }
399638
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($this->validator()->fails()) {
            $this->error($this->formatErrors());
            // Exit with status code 1
            return 1;
        }

        return parent::execute($input, $output);
    }
1273942
private function getAdministratorPassword(InputInterface $input, OutputInterface $output)
    {
        /**
         * @var QuestionHelper
         */
        $questionHelper = $this->getHelper('question');
        $validator = $this->getPasswordQuestionValidator($output);

        do {
            $passwordQuestion = $this->createPasswordQuestion('Choose password:', $validator);
            $confirmPasswordQuestion = $this->createPasswordQuestion('Confirm password:', $validator);

            $password = $questionHelper->ask($input, $output, $passwordQuestion);
            $repeatedPassword = $questionHelper->ask($input, $output, $confirmPasswordQuestion);

            if ($repeatedPassword !== $password) {
                $output->writeln('<error>Passwords do not match!</error>');
            }
        } while ($repeatedPassword !== $password);

        return $password;
    }
60242
public function output($output) {
		return fwrite($this->output, Text::insert($output, $this->styles()));
	}
873466
private function handleDownload(OutputInterface $output, $source)
	{
		$this->writeln($output, "Downloading $source", OutputInterface::VERBOSITY_VERBOSE);

		return $this->unpack(\JInstallerHelper::downloadPackage($source));
	}
419027
private function updateLockerInWorkingDirectory(Console\Output\OutputInterface $output, string $workingDirectory): int
    {
        return $this->getApplication()->run(
            new Console\Input\ArrayInput([
                'command' => 'update',
                '--lock' => true,
                '--no-autoloader' => true,
                '--no-plugins' => true,
                '--no-scripts' => true,
                '--no-suggest' => true,
                '--working-dir' => $workingDirectory,
            ]),
            $output
        );
    }
180460
protected function clearSymfonyCache(OutputInterface $output)
    {
        $command   = $this->getApplication()->find('cache:clear');
        $arguments = [
            'command' => 'cache:clear',
        ];

        return $command->run(new ArrayInput($arguments), $output) === 0;
    }
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);
        }
    }
436566
protected function makeConsoleLogger(OutputInterface $output): ConsoleLogger
    {
        return new ConsoleLogger($output, [
            LogLevel::DEBUG  => OutputInterface::VERBOSITY_VERY_VERBOSE,
            LogLevel::INFO   => OutputInterface::VERBOSITY_VERBOSE,
            LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL
        ], [
            LogLevel::DEBUG  => '',
            LogLevel::INFO   => '',
            LogLevel::NOTICE => 'info'
        ]);
    }
382069
public function create(OutputInterface $output) : LoggerInterface
    {
        $logger        = new Logger('browscap');
        $consoleLogger = new ConsoleLogger($output);
        $psrHandler    = new PsrHandler($consoleLogger);

        $logger->pushHandler($psrHandler);
        $logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, Logger::NOTICE));

        ErrorHandler::register($logger);

        return $logger;
    }
1343012
protected function ensureResponse($output)
    {
        if ($output instanceof Response)
        {
            return $output;
        }
        elseif (is_string($output))
        {
            return Response::create($output, 200);
        }
        else
        {
            $message = "Action response cannot be served.";
            throw new ApplicationException($message);
        }
    }
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;
    }
910022
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        $user = $this->findUser($output, $username);
        if (null === $user) {
            return 1;
        }

        $password = $this->getPassword($input, $output);
        if ($password) {
            $this->userManager->setPlainTextPassword($user, $password);
        } else {
            $this->userManager->requestNewPassword($user);
        }
        $this->userManager->save($user);

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

        return 0;
    }