Making xml help work.

Need to update tests.
This commit is contained in:
mark_story 2010-10-19 23:35:58 -04:00
parent 65686a0648
commit a6a627bd92
2 changed files with 17 additions and 5 deletions

View file

@ -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);
if ($format == 'text' || $format === true) {
return $formatter->text($width);
} elseif ($format == 'xml') {
return $formatter->xml();
}
}
/**

View file

@ -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);