setInput(new ArgvInput()); } public function fromStdin() { return $this->setInput(new ArrayInput($this->readStdin())); } public function toConsole() { return $this->setOutput(new ConsoleOutput); } public function toIRC() { return null; } public function __construct(InputInterface $input = null, OutputInterface $output = null) { $this->setInput($input)->setOutput($output); } public function setInput(InputInterface $input = null) { $this->input = $input; return $this; } public function setOutput(OutputInterface $output = null) { $this->output = $output; return $this; } public function run() { $this->application = new SymfonyApplication(); $commands = $this->commands(); foreach ($commands as $command) { $this->application->add($command); $this->application->setDefaultCommand($command->getName()); $this->application->run($this->input, $this->output); } } protected function readStdin() { $stream = fopen("php://stdin", "r"); $input_string = fgets($stream, 128); $input_string = rtrim($input_string); $input_array = explode(' ', $input_string); fclose($stream); return $input_array; } }