diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 9fc2afa84..50206318e 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -470,7 +470,7 @@ class ConsoleOptionParser { * @param int $width The width to format user content to. Defaults to 72 * @return string Generated help. */ - public function help($subcommand = null, $width = 72) { + public function help($subcommand = null, $format = 'text', $width = 72) { if ( isset($this->_subcommands[$subcommand]) && $this->_subcommands[$subcommand]->parser() instanceof self @@ -480,7 +480,11 @@ class ConsoleOptionParser { return $subparser->help(); } $formatter = new HelpFormatter($this); - return $formatter->text($width); + if ($format == 'text' || $format === true) { + return $formatter->text($width); + } elseif ($format == 'xml') { + return $formatter->xml(); + } } /** diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index 8a4c7ba19..96b02dda7 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -338,12 +338,20 @@ class Shell extends Object { list($this->params, $this->args) = $this->OptionParser->parse($argv, $command); $this->command = $command; + if (!empty($this->params['help'])) { + $isXml = false; + $format = 'text'; + if (!empty($this->args[0]) && $this->args[0] == 'xml') { + $format = 'xml'; + } else { + $this->_welcome(); + } + return $this->out($this->OptionParser->help($command, $format)); + } + if (($isTask || $isMethod || $isMain) && $command !== 'execute' ) { $this->startup(); } - if (!empty($this->params['help'])) { - return $this->out($this->OptionParser->help($command)); - } if ($isTask) { $command = Inflector::camelize($command);