@param QuestionHelper  $helper
@param InputInterface  $input
@param OutputInterface $output

@return bool|ApiContext
963647
public function restore(QuestionHelper $helper, InputInterface $input, OutputInterface $output)
    {
        if (!\file_exists($this->encyptedConfigurationFile)) {
            $output->writeln(
                \sprintf(
                    self::ERROR_FILE_NOT_EXISTS,
                    $this->encyptedConfigurationFile
                )
            );

            return false;
        }

        try {
            $password = $this->getPassword($helper, $input, $output);
            $encryptedContents = \file_get_contents($this->encyptedConfigurationFile);
            $json = $this->crypt->decrypt($encryptedContents, $password);

            $apiContext = ApiContext::fromJson($json);
            $apiContext->ensureSessionActive();

            // store it back with updated credentials
            $this->store($apiContext->toJson(), $password);

            BunqContext::loadApiContext($apiContext);

            return $apiContext;
        } catch (CryptException $exception) {
            $output->writeln(sprintf(self::ERROR_COULD_NOT_CRYPT, $exception->getMessage()));
        } catch (BunqException $exception) {
            $output->writeln(sprintf(self::ERROR_API_RESTORE, $exception->getMessage()));
        } catch (\Throwable $exception) {
            $output->writeln(sprintf(self::ERROR_GENERAL, $exception->getMessage()));
        }

        return false;
    }
1125422
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getQuestionHelper();

        $question = new ConfirmationQuestion('Do you confirm generation?', true);

        if ($input->isInteractive()) {
            if (!$helper->ask($input, $output, $question)) {
                $output->writeln('<error>Command aborted</error>');

                return 1;
            }
        }

        foreach (array('namespace', 'short-name') as $option) {
            if (null === $input->getOption($option)) {
                throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
            }
        }

        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'));
        $bundle = strtr($namespace, array('\\' => ''));
        $bundle = Validators::validateBundleName($bundle);

        $dir = realpath(__DIR__ . '/../../../../../../');
        if (null !== $input->getOption('dir')) {
            $dir = $input->getOption('dir');
        }

        $dir = Validators::validateTargetDir($dir, $bundle, $namespace);

        if (!$this->getContainer()->get('filesystem')->isAbsolutePath($dir)) {
            $dir = getcwd().'/'.$dir;
        }

        $format = 'yml';
        $format = Validators::validateFormat($format);

        $helper->writeSection($output, 'Bundle generation');

        /** @var ComponentGenerator $generator */
        $generator = $this->getGenerator();
        $generator->generate($namespace, $bundle, $dir, $format);

        $output->writeln('Generating the bundle code: <info>OK</info>');

        $errors = array();
        $runner = $helper->getRunner($output, $errors);

        //update parameters.yml file in vendor
        $shortName = $input->getOption('short-name');
        $runner($this->updateParameters($output, $shortName, $dir, $namespace, $bundle));

        $helper->writeGeneratorSummary($output, $errors);
    }
934688
protected function ask($question)
    {
        $helper = $this->getHelper('question');
        $question = new Question("<question>{$question}</question>");

        return $helper->ask($this->input, $this->output, $question);
    }
753601
private function askForSpecificResources(InputInterface $input, OutputInterface $output) {
        $resources = Resource::getAllResources();
        sort($resources);

        $question = new ChoiceQuestion(
            'Which resources should the public key have access to? (comma-separated) ',
            $resources
        );
        $question->setMultiselect(true);

        return $this->getHelper('question')->ask($input, $output, $question);
    }
368895
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getQuestionHelper();

        if ($input->isInteractive()) {
            $confirmationQuestion = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
            if (!$questionHelper->ask($input, $output, $confirmationQuestion)) {
                $output->writeln('<error>Command aborted</error>');

                return 1;
            }
        }

        GeneratorUtils::ensureOptionsProvided($input, array('namespace', 'dir'));

        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'));
        if (!$bundle = $input->getOption('bundle-name')) {
            $bundle = strtr($namespace, array('\\' => ''));
        }
        $bundle = Validators::validateBundleName($bundle);
        $dir = $this::validateTargetDir($input->getOption('dir'), $bundle, $namespace);
        $format = 'yml';

        $questionHelper->writeSection($output, 'Bundle generation');

        if (!$this
            ->getContainer()
            ->get('filesystem')
            ->isAbsolutePath($dir)
        ) {
            $dir = getcwd() . '/' . $dir;
        }

        $generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle('KunstmaanGeneratorBundle'));
        $generator->generate($namespace, $bundle, $dir, $format);

        $output->writeln('Generating the bundle code: <info>OK</info>');

        $errors = array();
        $runner = $questionHelper->getRunner($output, $errors);

        // check that the namespace is already autoloaded
        $runner($this->checkAutoloader($output, $namespace, $bundle));

        // register the bundle in the Kernel class
        $runner($this->updateKernel($questionHelper, $input, $output, $this->getContainer()->get('kernel'), $namespace, $bundle));

        // routing
        $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format));

        $questionHelper->writeGeneratorSummary($output, $errors);
    }
198861
public function ask(InputInterface $input, OutputInterface $output, Question $question)
    {
        if ($output instanceof ConsoleOutputInterface) {
            $output = $output->getErrorOutput();
        }

        if (!$input->isInteractive()) {
            $default = $question->getDefault();

            if (null === $default) {
                return $default;
            }

            if ($validator = $question->getValidator()) {
                return \call_user_func($question->getValidator(), $default);
            } elseif ($question instanceof ChoiceQuestion) {
                $choices = $question->getChoices();

                if (!$question->isMultiselect()) {
                    return isset($choices[$default]) ? $choices[$default] : $default;
                }

                $default = explode(',', $default);
                foreach ($default as $k => $v) {
                    $v = trim($v);
                    $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
                }
            }

            return $default;
        }

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

        if (!$question->getValidator()) {
            return $this->doAsk($output, $question);
        }

        $interviewer = function () use ($output, $question) {
            return $this->doAsk($output, $question);
        };

        return $this->validateAttempts($interviewer, $output, $question);
    }
1224456
protected function interact(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getHelper('question');
        $formatter = $this->getHelper('formatter');
        $rootDir = $this->getRootDir();
        $fs = new Filesystem();
        $appPath = explode('/', $rootDir);
        $appName = $appPath[count($appPath) - 2];

        $this->initConfig($fs, $rootDir);
        $output->writeln([$formatter->formatSection('SETUP', 'Project settings'), '']);

        $deployData = $this->configureDeploy($input, $output, $questionHelper, $appName);
        $deploy = new DeployGenerator($deployData, $rootDir);
        $this->generate($deploy);

        $output->writeln(['', " > generating <comment>{$appName}/config/deploy.rb</comment>"]);
        $output->writeln(['<info>Successfully created.</info>', '']);
        $output->writeln([$formatter->formatSection('PRODUCTION', 'Remote server / SSH settings'), '']);

        $sshProps = $this->configureSSH($input, $output, $questionHelper, $deployData);
        $staging = new StagingGenerator($sshProps, $this->getCapistranoDeployDir());
        $yamlStaging = new YamlStagingGenerator($sshProps, $this->getStagingsConfigDir());

        $this->generateMany([$staging, $yamlStaging]);

        return $output->writeln('<comment>Remote server successfully configured</comment>');
    }
1066878
private function confirmRemoval(
        InputInterface $input,
        OutputInterface $output,
        $countryCode
    ) {
        /**
         * @var QuestionHelper $questionHelper
         */
        $questionHelper = $this->getHelper('question');
        $message = "<question>Country with code '$countryCode' will be dropped. Continue?</question>";

        return $questionHelper->ask(
            $input,
            $output,
            new ConfirmationQuestion($message, false)
        );
    }
610
private function choice($question, array $choices, $default, InputInterface $input, OutputInterface $output)
    {
        $helper = new QuestionHelper();

        $result = $helper->ask($input, $output, new ChoiceQuestion(
            $question,
            $choices,
            $choices[$default]
        ));

        $output->writeln('');

        return $result;
    }
416226
public function set(HelperInterface $helper, $alias = null)
    {
        $this->helpers[$helper->getName()] = $helper;
        if (null !== $alias) {
            $this->helpers[$alias] = $helper;
        }

        $helper->setHelperSet($this);
    }
148552
private static function getApplicationName(InputInterface $input, OutputInterface $output, QuestionHelper $helper)
    {
        $question = new Question('Choose your application name: ');
        $question->setValidator(function($answer) {
            if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $answer)) {
                throw new \InvalidArgumentException('The application name contains invalid characters.');
            }

            return ucfirst(strtolower($answer));
        });

        return $helper->ask($input, $output, $question);
    }
610367
protected function getQueueInformation(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
    {
        if ($input->getOption('queue-disabled')) {
            return null;
        }

        $rtn = [];

        $helper = $this->getHelper('question');
        $question = new ConfirmationQuestion('Use beanstalkd to manage build queue? ', true);

        if (!$helper->ask($input, $output, $question)) {
            $output->writeln('<error>Skipping beanstalkd configuration.</error>');
            return null;
        }

        if (!$rtn['host'] = $input->getOption('queue-server')) {
            $rtn['host'] = $dialog->ask($output, 'Enter your beanstalkd hostname [localhost]: ', 'localhost');
        }

        if (!$rtn['queue'] = $input->getOption('queue-name')) {
            $rtn['queue'] = $dialog->ask($output, 'Enter the queue (tube) name to use [phpci]: ', 'phpci');
        }

        return $rtn;
    }
350664
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output, false);
        $domains = $input->getOption('domain');
        $languages = $input->getOption('language');
        $project = $this->createProjectByInput($input);
        $questionHelper = $this->getHelper('question');

        while (true) {
            $randomTranslation = $project->getRandomMissingTranslation(
                $domains,
                $languages
            );

            if (!($randomTranslation instanceof Translation)) {
                $this
                    ->printMessage(
                        $output,
                        'Trans Server',
                        'No more translations for you!'
                    );

                break;
            }

            $this->printMessage(
                $output,
                'Trans Server',
                'Language : ' . $randomTranslation->getLanguage()
            );
            $this->printMessage(
                    $output,
                    'Trans Server',
                    'Key : ' . $randomTranslation->getKey()
                );
            $this->printMessage(
                    $output,
                    'Trans Server',
                    'Original : ' . $randomTranslation
                        ->getMasterTranslation()
                        ->getValue()
                );

            $question = new Question('[Trans Server] Translation : ');
            $translationValue = $questionHelper->ask(
                $input,
                $output,
                $question
            );

            if (false === $translationValue) {
                break;
            }

            $randomTranslation->setValue($translationValue);
            $masterStructure = $randomTranslation->getStructure();
            $this->overwriteLastValueFromStructure(
                $masterStructure,
                $translationValue
            );
            $randomTranslation->setStructure($masterStructure);

            $project->addTranslation($randomTranslation);
            $project->save();
            $output->writeln('');
        }

        $this->finishCommand($output);
    }
404287
protected function getPassword(QuestionHelper $helper, InputInterface $input, OutputInterface $output)
    {
        $question = new Question(self::PROMPT_PASSWORD);
        $question->setHidden(true);
        $question->setHiddenFallback(false);
        $question->setNormalizer(function ($value) {
            return $value ? trim($value) : false;
        });

        // the big question
        $password = $helper->ask($input, $output, $question);
        if (false === $password) {
            throw new RuntimeException(self::ERROR_NO_PASSWORD_SUPPLIED);
        }

        return $password;
    }
189224
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$this->apiHelper->restore($this->getHelper('question'), $input, $output)) {
            return;
        }

        $output->writeln(\sprintf('Checking for URL: <info>%s</info>', $this->getUrl()).PHP_EOL);

        /** @var QuestionHelper $asker */
        $asker = $this->getHelper('question');
        $user = $this->apiHelper->currentUser();

        $enabled = $this->getCallbackStatus($user);
        $question = new ConfirmationQuestion(
            sprintf(
                '%s [y/N]: ',
                $enabled
                    ? 'The callback is currently <info>ACTIVE</info>, would you like to disable?'
                    : 'The callback is currently <info>INACTIVE</info>, would you like to enable?'
            ),
            false
        );

        if (!$asker->ask($input, $output, $question)) {
            return;
        }

        try {
            if ($enabled) {
                $this->disableCallback($user);
            } else {
                $this->enableCallback($user);
            }

            $output->writeln('<info>New status successfully applied.</info>');
        } catch (BunqException $exception) {
            $output->writeln('<error>An error occured while applying new status: '.$exception->getMessage().'</error>');
        }
    }
1260967
public static function getInstance(OutputInterface $output, InputInterface $input)
    {
        $questionHelper = new QuestionHelper();
        $application    = new Application('Code Generator Command Line Interface', 'Alpha');
        $application->getHelperSet()->set(new FormatterHelper(), 'formatter');
        $application->getHelperSet()->set($questionHelper, 'question');

        $context = new CliContext(
            $questionHelper,
            $output,
            $input,
            CreateCommandFactory::getInstance($application)
        );

        $mainBackbone = MainBackboneFactory::getInstance($context);

        $mainBackbone->run();

        return $application;
    }
881010
public static function installAvooDemoBundle(InputInterface $input, OutputInterface $output, QuestionHelper $helper)
    {
        $rootDir = getcwd();

        if (file_exists($rootDir.'/src/Avoo/DemoBundle')) {
            return;
        }
        if (!getenv('AVOO_DEMO')) {
            $question = new ConfirmationQuestion('Would you like to install Avoo Demo bundle? [y/n] ', true);
            if (!$helper->ask($input, $output, $question)) {
                return;
            }
        }

        $output->writeln('<info>Installing the Avoo Demo bundle.</info>');
        $output->writeln('');

        $kernelFile = $rootDir . '/app/AppKernel.php';
        $configFile = $rootDir . '/app/config/config_dev.yml';

        $fileSystem = new Filesystem();
        $fileSystem->mirror(__DIR__.'/../Resources/skeleton/avoo-demo-bundle', $rootDir . '/src', null, array('override' => true));

        $ref = '$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();';
        $bundleDeclaration = "\$bundles[] = new \\Avoo\\DemoBundle\\AvooDemoBundle();";
        $content = file_get_contents($kernelFile);

        if (false === strpos($content, $bundleDeclaration)) {
            $updatedContent = str_replace($ref, $bundleDeclaration."\n            ".$ref, $content);
            if ($content === $updatedContent) {
                throw new \RuntimeException('Unable to patch %s.', $kernelFile);
            }

            $fileSystem->dumpFile($kernelFile, $updatedContent);
        }

        $ref = '- { resource: config.yml }';
        $configDeclaration = '- { resource: @AvooDemoBundle/Resources/config/config.yml }';
        $content = file_get_contents($configFile);

        if (false === strpos($content, $bundleDeclaration)) {
            $updatedContent = str_replace($ref, $ref . "\n    " . $configDeclaration, $content);
            if ($content === $updatedContent) {
                throw new \RuntimeException('Unable to patch %s.', $kernelFile);
            }

            $fileSystem->dumpFile($configFile, $updatedContent);
        }

        self::patchAvooDemoBundleConfiguration($rootDir, $fileSystem);
    }