Skip to content
Permalink
Browse files

Making description() and epilog() accept arrays.

  • Loading branch information...
markstory committed Oct 10, 2010
1 parent 412864c commit b5630a5e308ca91f721ec3be40121e66e016a225
Showing with 14 additions and 2 deletions.
  1. +8 −2 cake/console/console_option_parser.php
  2. +6 −0 cake/tests/cases/console/console_option_parser.test.php
@@ -184,11 +184,14 @@ public function command($text = null) {
/**
* Get or set the description text for shell/task
*
* @param string $text The text to set, or null if you want to read
* @param mixed $text The text to set, or null if you want to read. . If an array the text will be imploded with "\n"
* @return mixed If reading, the value of the description. If setting $this will be returned
*/
public function description($text = null) {
if ($text !== null) {
if (is_array($text)) {
$text = implode("\n", $text);
}
$this->_description = $text;
return $this;
}
@@ -199,11 +202,14 @@ public function description($text = null) {
* Get or set an epilog to the parser. The epilog is added to the end of
* the options and arguments listing when help is generated.
*
* @param string $text Text when setting or null when reading.
* @param mixed $text Text when setting or null when reading. If an array the text will be imploded with "\n"
* @return mixed If reading, the value of the epilog. If setting $this will be returned.
*/
public function epilog($text = null) {
if ($text !== null) {
if (is_array($text)) {
$text = implode("\n", $text);
}
$this->_epilog = $text;
return $this;
}
@@ -33,6 +33,9 @@ function testDescription() {
$this->assertEquals($parser, $result, 'Setting description is not chainable');
$this->assertEquals('A test', $parser->description(), 'getting value is wrong.');
$result = $parser->description(array('A test', 'something'));
$this->assertEquals("A test\nsomething", $parser->description(), 'getting value is wrong.');
}
/**
@@ -46,6 +49,9 @@ function testEpilog() {
$this->assertEquals($parser, $result, 'Setting epilog is not chainable');
$this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.');
$result = $parser->epilog(array('A test', 'something'));
$this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.');
}
/**

0 comments on commit b5630a5

Please sign in to comment.
You can’t perform that action at this time.