diff --git a/cake/console/console_option_parser.php b/cake/console/console_option_parser.php
index b3a25e997..25d011b44 100644
--- a/cake/console/console_option_parser.php
+++ b/cake/console/console_option_parser.php
@@ -270,6 +270,10 @@ class ConsoleOptionParser {
*/
public function help() {
$out = array();
+ if (!empty($this->_description)) {
+ $out[] = $this->_description;
+ $out[] = '';
+ }
$out[] = 'Usage:';
$out[] = $this->_generateUsage();
$out[] = '';
@@ -299,6 +303,9 @@ class ConsoleOptionParser {
}
$out[] = '';
}
+ if (!empty($this->_epilog)) {
+ $out[] = $this->_epilog;
+ }
return implode("\n", $out);
}
diff --git a/cake/tests/cases/console/console_option_parser.test.php b/cake/tests/cases/console/console_option_parser.test.php
index d527ec79f..2dcfd0af0 100644
--- a/cake/tests/cases/console/console_option_parser.test.php
+++ b/cake/tests/cases/console/console_option_parser.test.php
@@ -228,7 +228,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
*
* @return void
*/
- function testGetHelpWithOptions() {
+ function testHelpWithOptions() {
$parser = new ConsoleOptionParser('mycommand', false);
$parser->addOption('test', array('help' => 'A test option.'))
->addOption('connection', array(
@@ -255,7 +255,7 @@ TEXT;
*
* @return void
*/
- function testGetHelpWithOptionsAndArguments() {
+ function testHelpWithOptionsAndArguments() {
$parser = new ConsoleOptionParser('mycommand', false);
$parser->addOption('test', array('help' => 'A test option.'))
->addArgument('model', array('help' => 'The model to make.', 'required' => true))
@@ -279,4 +279,37 @@ other_longer Another argument. (optional)
TEXT;
$this->assertEquals($expected, $result, 'Help does not match');
}
+
+/**
+ * test description and epilog in the help
+ *
+ * @return void
+ */
+ function testDescriptionAndEpilog() {
+ $parser = new ConsoleOptionParser('mycommand', false);
+ $parser->description('Description text')
+ ->epilog('epilog text')
+ ->addOption('test', array('help' => 'A test option.'))
+ ->addArgument('model', array('help' => 'The model to make.', 'required' => true));
+
+ $result = $parser->help();
+ $expected = <<Usage:
+cake mycommand [-h] [--test] model
+
+Options:
+
+--help, -h Display this help.
+--test A test option.
+
+Arguments:
+
+model The model to make.
+
+epilog text
+TEXT;
+ $this->assertEquals($expected, $result, 'Help is wrong.');
+ }
}
\ No newline at end of file