Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Symfony/Component/Console/Helper/DialogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Console\Helper;

use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;

Expand Down Expand Up @@ -42,6 +43,10 @@ class DialogHelper extends Helper
*/
public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$width = max(array_map('strlen', array_keys($choices)));

$messages = (array) $question;
Expand Down Expand Up @@ -98,6 +103,10 @@ public function select(OutputInterface $output, $question, $choices, $default =
*/
public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$output->write($question);

$inputStream = $this->inputStream ?: STDIN;
Expand Down Expand Up @@ -230,6 +239,10 @@ public function ask(OutputInterface $output, $question, $default = null, array $
*/
public function askConfirmation(OutputInterface $output, $question, $default = true)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$answer = 'z';
while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {
$answer = $this->ask($output, $question);
Expand All @@ -255,6 +268,10 @@ public function askConfirmation(OutputInterface $output, $question, $default = t
*/
public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

if ('\\' === DIRECTORY_SEPARATOR) {
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';

Expand Down Expand Up @@ -332,6 +349,10 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
*/
public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$that = $this;

$interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
Expand Down Expand Up @@ -361,6 +382,10 @@ public function askAndValidate(OutputInterface $output, $question, $validator, $
*/
public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$that = $this;

$interviewer = function () use ($output, $question, $fallback, $that) {
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Console/Helper/ProgressHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Console\Helper;

use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -182,6 +183,10 @@ public function setRedrawFrequency($freq)
*/
public function start(OutputInterface $output, $max = null)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}

$this->startTime = time();
$this->current = 0;
$this->max = (int) $max;
Expand Down