@param InputInterface  $input
@param OutputInterface $output
@param string          $questionText
@param string          $default
@param string          $separator

@return string
335862
private function askConfirmation(InputInterface $input, OutputInterface $output, $questionText, $default, $separator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            $question = $questionHelper->getQuestion($questionText, $default, $separator);

            return $questionHelper->askConfirmation($output, $question, ($default === 'no' ? false : true));
        }

        $question = new ConfirmationQuestion($questionHelper->getQuestion(
            $questionText,
            $default,
            $separator
        ), ($default === 'no' ? false : true));

        return $questionHelper->ask($input, $output, $question);
    }
1349202
public function text(InputInterface $input, OutputInterface $output)
    {
        foreach ($this->router->getRoutes() as $route) {
            if (!empty($route->getName())) {
                $output->writeln('<fg=cyan;options=bold>'.$route->getName().'</>');
                $output->writeln('    '.implode(', ', $route->getMethods()));
                $output->writeln('    '.$route->getPattern());
                if (is_string($route->getCallable())) {
                    $output->writeln('    '.$route->getCallable());
                }

                $output->writeln('');
            }
        }
    }
1125077
protected function doAsk(OutputInterface $output, Question $question, $formats = [])
	{
		$this->writePrompt($output, $question, $formats);

		$inputStream = $this->inputStream ?: STDIN;

		$ret = fgets($inputStream, 4096);

		if (false === $ret) {
			throw new RuntimeException('Aborted');
		}

		$ret = trim($ret);
		$ret = strlen($ret) > 0 ? $ret : $question->getDefault();

		if ($question instanceof ChoiceQuestion) {
			$ret = $this->matchChoice($question, $ret);
		}

		if ($normalizer = $question->getNormalizer()) {
			return $normalizer($ret);
		}

		return $ret;
	}
999730
protected function configureSSH(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper, $deployData)
    {
        $serverOptions = [
            'domain' => [
                'helper' => $deployData['ssh_user'],
                'label'  => 'Domain name',
            ],
        ];
        $sshOptions = [
            'forwardAgent' => [
                'label'  => 'SSH forward agent',
                'helper' => 'false',
            ],
            'authMethods' => [
                'label'  => 'SSH auth method',
                'helper' => 'publickey password',
            ],
            'keys' => [
                'label'  => 'Remote SSH key',
                'helper' => sprintf('/home/%s/.ssh/id_rsa', $deployData['ssh_user']),
            ],
        ];
        $sshProps = [
          'user'         => $deployData['ssh_user'],
          'keys'         => '',
          'forwardAgent' => false,
          'authMethods'  => 'publickey password',
          'deployTo'     => $deployData['deploy_to'],
          'repoUrl'      => $deployData['repo_url'],
        ];

        $question = new Question("<info>{$serverOptions['domain']['label']}</info> [<comment>{$serverOptions['domain']['helper']}</comment>]: ", $serverOptions['domain']['helper']);
        $sshProps['domain'] = $questionHelper->ask($input, $output, $question);

        foreach ($sshOptions as $key => $property) {
            $question = new Question("<info>{$property['label']}</info> [<comment>{$property['helper']}</comment>]: ", $property['helper']);

            if (isset($property['autocomplete'])) {
                $question->setAutocompleterValues($property['autocomplete']);
            }

            $sshProps[$key] = $questionHelper->ask($input, $output, $question);
        }

        return $sshProps;
    }
364033
private function getQuestion($question, $default = null, callable $validator = null, array $values = null)
    {
        $question = new Question(
            sprintf('<info>%s</info>%s: ', $question, $default ? sprintf(' [<comment>%s</comment>]', $default) : ''),
            $default
        );

        $question
            ->setValidator($validator)
            ->setAutocompleterValues($values);

        return $question;
    }
267994
private function askForDocument(InputInterface $input, OutputInterface $output, QuestionHelper $dialog)
    {
        do {
            $retry = true;
            $question = new Question($dialog->getQuestion('The Document shortcut name', $input->getOption('document')), $input->getOption('document'));
            $question->setValidator(array(
                'IsmaAmbrosi\Bundle\GeneratorBundle\Command\Validators',
                'validateDocumentName',
            ), $input->getOption('document'));
            $document = $dialog->ask($input, $output, $question);

            list($bundle, $document) = $this->parseShortcutNotation($document);

            try {
                $b = $this->getKernel()->getBundle($bundle);

                if (!file_exists($b->getPath().'/Document/'.str_replace('\\', '/', $document).'.php')) {
                    $retry = false;
                } else {
                    $output->writeln(sprintf('<bg=red>Document "%s:%s" already exists</>.', $bundle, $document));
                }
            } catch (\Exception $e) {
                $output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
            }
        } while ($retry);
        $input->setOption('document', $bundle.':'.$document);

        return array($bundle, $document);
    }
994329
public function askThenRemove(InputInterface $input, OverwritableOutputInterface $output, Question $question)
    {
        // Following suit of ask().
        if (!$input->isInteractive()) {
            return $question->getDefault();
        }

        $this->remove = true;
        $this->question = $question;
        $this->output = $output;
        $this->autocomplete = $this->question->getAutocompleterValues() !== null && $this->hasSttyAvailable();

        $this->output->capture();

        // Wrap normalizer to remove latest question & answer since
        // it is called for each iteration if answer is not valid.
        $normalizer = $question->getNormalizer();
        $question->setNormalizer(function ($value) use ($normalizer) {
            $this->output->remove();
            $this->output->capture();

            if (is_callable($normalizer)) {
                return $normalizer($value);
            }

            return $value;
        });

        try {
            $value = $this->ask($input, $this->output, $question);
        } finally {
            $this->remove = false;
            $this->question = null;
            $this->output->remove();
            $this->output = null;
        }

        return $value;
    }
797085
protected function execute( InputInterface $input, OutputInterface $output )
	{
		$code = $input->getArgument( 'email' );
		if( ( $password = $input->getOption( 'password' ) ) === null )
		{
			$helper = $this->getHelper( 'question' );
			$question = new Question( 'Password' );
			$question->setHidden( true );

			$password = $helper->ask( $input, $output, $question );
		}

		$context = $this->getContainer()->get( 'aimeos.context' )->get( false, 'command' );
		$context->setEditor( 'aimeos:account' );

		$localeManager = \Aimeos\MShop::create( $context, 'locale' );
		$localeItem = $localeManager->bootstrap( $input->getArgument( 'site' ), '', '', false );
		$context->setLocale( $localeItem );

		$user = $this->createCustomerItem( $context, $code, $password );

		if( $input->getOption( 'admin' ) ) {
			$this->addGroup( $input, $output, $context, $user, 'admin' );
		}

		if( $input->getOption( 'editor' ) ) {
			$this->addGroup( $input, $output, $context, $user, 'editor' );
		}

		if( $this->getContainer()->has( 'fos_user.user_manager' ) )
		{
			$userManager = $this->getContainer()->get( 'fos_user.user_manager' );

			if( ( $fosUser = $userManager->findUserByUsername( $code ) ) === null ) {
				throw new \RuntimeException( 'No user created' );
			}

			$fosUser->setSuperAdmin( false );

			if( $input->getOption( 'super' ) ) {
				$fosUser->setSuperAdmin( true );
			}

			if( $input->getOption( 'admin' ) || $input->getOption( 'editor' ) ) {
				$fosUser->addRole( 'ROLE_ADMIN' );
			}

			$userManager->updateUser( $fosUser );
		}
	}
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>');
    }
541575
protected function ask($question, $default = null, $validator = null)
    {
        return $this->output->ask($question, $default, $validator);
    }
1370801
private function askForFieldName(InputInterface $input, OutputInterface $output, QuestionHelper $dialog, $fields)
    {
        $question = new Question($dialog->getQuestion('New field name (press <return> to stop adding fields)', null));
        $question->setValidator(function ($name) use ($fields) {
            if (isset($fields[$name]) || 'id' == $name) {
                throw new \InvalidArgumentException(sprintf('Field "%s" is already defined.', $name));
            }

            return $name;
        });

        return $dialog->ask($input, $output, $question);
    }
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);
    }
199622
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $questionHelper = $this->getQuestionHelper();

        GeneratorUtils::ensureOptionsProvided($input, array('entity'));

        $entity = Validators::validateEntityName($input->getOption('entity'));
        list($bundle, $entity) = $this->parseShortcutNotation($entity);

        $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
        $metadata = $this->getEntityMetadata($entityClass);
        /** @var Bundle $bundle */
        $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);

        $questionHelper->writeSection($output, 'AdminList Generation');

        /** @var AdminListGenerator $generator */
        $generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle("KunstmaanGeneratorBundle"));
        $generator->setQuestion($questionHelper);
        $generator->generate($bundle, $entityClass, $metadata[0], $output, $input->getOption('sortfield'));

        $parts = explode('\\', $entity);
        $entityClass = array_pop($parts);

        $generator->generateRouting($bundle, $entityClass);
    }
464546
public function run(InputInterface $input, OutputInterface $output)
    {
        $template = new Template();
        $template = $template->initialize();

        $data = ['command' => $this->_controllerData];
        $content = $template->parse($this->_template)->process($data);

        $fileName = $this->_getFileName();
        $folder = new Folder(['name' => $this->getPath()]);
        if (
            !$folder->hasFolder(
                lcfirst($this->_controllerData->getControllerSimpleName())
            )
        ) {
            $folder->addFolder(
                lcfirst($this->_controllerData->getControllerSimpleName())
            );
        }

        /** @var QuestionHelper $dialog */
        $dialog = $this->_command->getHelperSet()->get('question');
        $name = $folder->details->getRealPath() . '/'. $fileName;
        $save = true;

        if ($folder->hasFile($fileName)) {
            $output->writeln("<comment>File '{$name}' already exists.</comment>");
            $question = new Question(
                '<question>Do you want to override existing file?</question>',
                false
            );
            if (!$dialog->ask($input, $output, $question)) {
                $save = false;
            }
        }

        if ($save) {
            $folder->addFile($fileName)
                ->write($content);
            $output->writeln("<info>{$this->_objectType} file generated successfully!</info>");
        } else {
            $output->writeln("<comment>{$this->_objectType} file was not created.</comment>");
        }
        $output->writeln('');
    }
342755
public function ask($question, $default = null)
    {
        $que = new Question($question, $default);
        $helper = new SymfonyQuestionHelper();
        return $helper->ask($this->input, $this->output, $que);
    }
370749
public function ask($text, $default = '', $displayDefault = true)
    {
        if ($displayDefault && !empty($default)) {
            $defaultText = $default;
            if (strlen($defaultText) > 30) {
                $defaultText = substr($default, 0, 30) . '...';
            }
            $text .= " [$defaultText]";
        }
        $this->textWriter->write("$text ");
        return trim(fgets(STDIN)) ?: $default;
    }
1136485
private function askConfirmation(InputInterface $input, OutputInterface $output, $question, $default)
    {
        if (!class_exists(ConfirmationQuestion::class)) {
            $dialog = $this->getHelperSet()->get('dialog');

            return $dialog->askConfirmation($output, $question, $default);
        }

        $questionHelper = $this->getHelperSet()->get('question');
        $question = new ConfirmationQuestion($question, $default);

        return $questionHelper->ask($input, $output, $question);
    }