Skip to content

Commit

Permalink
added getNativeDefinition() to allow specifying an alternate InputDef…
Browse files Browse the repository at this point in the history
…inition for help generation
  • Loading branch information
Andreas Hucks committed Mar 12, 2012
1 parent 0d89f13 commit 45bbb5b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Symfony/Component/Console/Command/Command.php
Expand Up @@ -298,6 +298,19 @@ public function getDefinition()
return $this->definition;
}

/**
* Gets the InputDefinition to be used to create XML and Text representations of this Command.
*
* Can be overridden to provide the original command representation when it would otherwise
* be changed by merging with the application InputDefinition.
*
* @return InputDefinition An InputDefinition instance
*/
protected function getNativeDefinition()
{
return $this->getDefinition();
}

/**
* Adds an argument.
*
Expand Down Expand Up @@ -531,7 +544,7 @@ public function asText()
$messages[] = '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>';
}

$messages[] = $this->definition->asText();
$messages[] = $this->getNativeDefinition()->asText();

if ($help = $this->getProcessedHelp()) {
$messages[] = '<comment>Help:</comment>';
Expand Down Expand Up @@ -572,7 +585,7 @@ public function asXml($asDom = false)
$aliasXML->appendChild($dom->createTextNode($alias));
}

$definition = $this->definition->asXml(true);
$definition = $this->getNativeDefinition()->asXml(true);
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true));
$commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true));

Expand Down

0 comments on commit 45bbb5b

Please sign in to comment.