Skip to content

Commit

Permalink
[Console] Consider STDIN interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Oct 7, 2019
1 parent 7df0b6c commit eca5b0d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -864,18 +864,6 @@ protected function configureIO(InputInterface $input, OutputInterface $output)

if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
$input->setInteractive(false);
} else {
$inputStream = null;

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

$inputStream = !$inputStream && \defined('STDIN') ? STDIN : $inputStream;

if ((!$inputStream || !stream_isatty($inputStream)) && false === getenv('SHELL_INTERACTIVE')) {
$input->setInteractive(false);
}
}

switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
Expand Down
@@ -0,0 +1,28 @@
--STDIN--
Hello World
--FILE--
<?php

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

(new Application())
->register('app')
->setCode(function(InputInterface $input, OutputInterface $output) {
$output->writeln((new QuestionHelper())->ask($input, $output, new Question('Foo?')));
})
->getApplication()
->setDefaultCommand('app', true)
->run()
;
--EXPECT--
Foo?Hello World

0 comments on commit eca5b0d

Please sign in to comment.