Browse files

Making first parameter of Shell::out() and err() optional.

  • Loading branch information...
1 parent 8627435 commit 0f6bca7496dab8faa9e58f0dbaec14ffd7c0b961 @davidpersson davidpersson committed Sep 26, 2009
Showing with 12 additions and 4 deletions.
  1. +6 −4 cake/console/libs/shell.php
  2. +6 −0 cake/tests/cases/console/libs/shell.test.php
View
10 cake/console/libs/shell.php
@@ -363,27 +363,29 @@ function in($prompt, $options = null, $default = null) {
}
/**
- * Outputs a single or multiple messages to stdout.
+ * Outputs a single or multiple messages to stdout. If no parameters
+ * are passed outputs just a newline.
*
* @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append
* @access public
*/
- function out($message, $newlines = 1) {
+ function out($message = null, $newlines = 1) {
if (is_array($message)) {
$message = implode($this->nl(), $message);
}
$this->Dispatch->stdout($message . $this->nl($newlines), false);
}
/**
- * Outputs a single or multiple error messages to stderr.
+ * Outputs a single or multiple error messages to stderr. If no parameters
+ * are passed outputs just a newline.
*
* @param mixed $message A string or a an array of strings to output
* @param integer $newlines Number of newlines to append
* @access public
*/
- function err($message, $newlines = 1) {
+ function err($message = null, $newlines = 1) {
if (is_array($message)) {
$message = implode($this->nl(), $message);
}
View
6 cake/tests/cases/console/libs/shell.test.php
@@ -235,6 +235,9 @@ function testOut() {
$this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false));
$this->Shell->out(array('Just', 'a', 'test'), 2);
+
+ $this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false));
+ $this->Shell->out();
}
/**
@@ -252,6 +255,9 @@ function testErr() {
$this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n"));
$this->Shell->err(array('Just', 'a', 'test'), 2);
+
+ $this->Shell->Dispatch->expectAt(3, 'stderr', array("\n", false));
+ $this->Shell->err();
}
/**

0 comments on commit 0f6bca7

Please sign in to comment.