Skip to content

Commit

Permalink
Making xml help work.
Browse files Browse the repository at this point in the history
Need to update tests.
  • Loading branch information
markstory committed Oct 20, 2010
1 parent 65686a0 commit a6a627b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cake/console/libs/console_option_parser.php
Expand Up @@ -470,7 +470,7 @@ public function parse($argv, $command = null) {
* @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
Expand All @@ -480,7 +480,11 @@ public function help($subcommand = null, $width = 72) {
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();
}
}

/**
Expand Down
14 changes: 11 additions & 3 deletions cake/console/shells/shell.php
Expand Up @@ -338,12 +338,20 @@ public function runCommand($command, $argv) {
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);
Expand Down

0 comments on commit a6a627b

Please sign in to comment.