public function Shell::run in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Shell.php \Symfony\Component\Console\Shell::run()
Runs the shell.
File
- vendor/
symfony/ console/ Shell.php, line 55
Class
- Shell
- A Shell wraps an Application to add shell capabilities to it.
Namespace
Symfony\Component\ConsoleCode
public function run() {
$this->application
->setAutoExit(false);
$this->application
->setCatchExceptions(true);
if ($this->hasReadline) {
readline_read_history($this->history);
readline_completion_function(array(
$this,
'autocompleter',
));
}
$this->output
->writeln($this
->getHeader());
$php = null;
if ($this->processIsolation) {
$finder = new PhpExecutableFinder();
$php = $finder
->find();
$this->output
->writeln(<<<EOF
<info>Running with process isolation, you should consider this:</info>
* each command is executed as separate process,
* commands don't support interactivity, all params must be passed explicitly,
* commands output is not colorized.
EOF
);
}
while (true) {
$command = $this
->readline();
if (false === $command) {
$this->output
->writeln("\n");
break;
}
if ($this->hasReadline) {
readline_add_history($command);
readline_write_history($this->history);
}
if ($this->processIsolation) {
$pb = new ProcessBuilder();
$process = $pb
->add($php)
->add($_SERVER['argv'][0])
->add($command)
->inheritEnvironmentVariables(true)
->getProcess();
$output = $this->output;
$process
->run(function ($type, $data) use ($output) {
$output
->writeln($data);
});
$ret = $process
->getExitCode();
}
else {
$ret = $this->application
->run(new StringInput($command), $this->output);
}
if (0 !== $ret) {
$this->output
->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
}
}
}