|
@@ -15,6 +15,7 @@ namespace Composer\IO;
|
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
use Symfony\Component\Console\Output\StreamOutput;
|
|
use Symfony\Component\Console\Output\StreamOutput;
|
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
|
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
|
|
|
+use Symfony\Component\Console\Input\StreamableInputInterface;
|
|
use Symfony\Component\Console\Input\StringInput;
|
|
use Symfony\Component\Console\Input\StringInput;
|
|
use Symfony\Component\Console\Helper\HelperSet;
|
|
use Symfony\Component\Console\Helper\HelperSet;
|
|
|
|
|
|
@@ -59,4 +60,27 @@ class BufferIO extends ConsoleIO
|
|
|
|
|
|
return $output;
|
|
return $output;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function setUserInputs(array $inputs)
|
|
|
|
+ {
|
|
|
|
+ if (!$this->input instanceof StreamableInputInterface) {
|
|
|
|
+ throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->input->setStream($this->createStream($inputs));
|
|
|
|
+ $this->input->setInteractive(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function createStream(array $inputs)
|
|
|
|
+ {
|
|
|
|
+ $stream = fopen('php://memory', 'r+', false);
|
|
|
|
+
|
|
|
|
+ foreach ($inputs as $input) {
|
|
|
|
+ fwrite($stream, $input.PHP_EOL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rewind($stream);
|
|
|
|
+
|
|
|
|
+ return $stream;
|
|
|
|
+ }
|
|
}
|
|
}
|