Skip to content

Commit

Permalink
Initial integration of ConsoleOutput into cake console tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 14, 2010
1 parent 5c55c28 commit ce4fe64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cake/console/console_output.php
@@ -1,6 +1,6 @@
<?php
/**
* ConsoleOutput file.
* ConsoleOutput file.
*
* PHP 5
*
Expand Down
14 changes: 6 additions & 8 deletions cake/console/shell_dispatcher.php
Expand Up @@ -17,6 +17,8 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
require_once 'console_output.php';

/**
* Shell dispatcher handles dispatching cli commands.
*
Expand Down Expand Up @@ -174,8 +176,8 @@ function __initConstants() {
*/
protected function _initEnvironment() {
$this->stdin = fopen('php://stdin', 'r');
$this->stdout = fopen('php://stdout', 'w');
$this->stderr = fopen('php://stderr', 'w');
$this->stdout = new ConsoleOutput('php://stdout');
$this->stderr = new ConsoleOutput('php://stderr');

if (!$this->__bootstrap()) {
$this->stderr("\nCakePHP Console: ");
Expand Down Expand Up @@ -454,11 +456,7 @@ public function getInput($prompt, $options = null, $default = null) {
* @return integer Returns the number of bytes output to stdout.
*/
public function stdout($string, $newline = true) {
if ($newline) {
return fwrite($this->stdout, $string . "\n");
} else {
return fwrite($this->stdout, $string);
}
return $this->stdout->write($string, $newline);
}

/**
Expand All @@ -467,7 +465,7 @@ public function stdout($string, $newline = true) {
* @param string $string Error text to output.
*/
public function stderr($string) {
fwrite($this->stderr, $string);
$this->stderr->write($string, false);
}

/**
Expand Down

0 comments on commit ce4fe64

Please sign in to comment.