Merging some fixes to Symfony Console component
This commit is contained in:
parent
59f3fe3a40
commit
efb33a8365
@ -488,7 +488,7 @@ class Application
|
||||
{
|
||||
// namespace
|
||||
$namespace = '';
|
||||
if (false !== $pos = strpos($name, ':'))
|
||||
if (false !== $pos = strrpos($name, ':'))
|
||||
{
|
||||
$namespace = $this->findNamespace(substr($name, 0, $pos));
|
||||
$name = substr($name, $pos + 1);
|
||||
|
@ -276,7 +276,7 @@ class Command
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
if (false !== $pos = strpos($name, ':'))
|
||||
if (false !== $pos = strrpos($name, ':'))
|
||||
{
|
||||
$namespace = substr($name, 0, $pos);
|
||||
$name = substr($name, $pos + 1);
|
||||
@ -375,6 +375,28 @@ class Command
|
||||
return $this->help;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the processed help for the command replacing the %command.name% and
|
||||
* %command.full_name% patterns with the real values dynamically.
|
||||
*
|
||||
* @return string The processed help for the command
|
||||
*/
|
||||
public function getProcessedHelp()
|
||||
{
|
||||
$name = $this->namespace.':'.$this->name;
|
||||
|
||||
$placeholders = array(
|
||||
'%command.name%',
|
||||
'%command.full_name%'
|
||||
);
|
||||
$replacements = array(
|
||||
$name,
|
||||
$_SERVER['PHP_SELF'].' '.$name
|
||||
);
|
||||
|
||||
return str_replace($placeholders, $replacements, $this->getHelp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the aliases for the command.
|
||||
*
|
||||
@ -457,7 +479,7 @@ class Command
|
||||
|
||||
$messages[] = $this->definition->asText();
|
||||
|
||||
if ($help = $this->getHelp())
|
||||
if ($help = $this->getProcessedHelp())
|
||||
{
|
||||
$messages[] = '<comment>Help:</comment>';
|
||||
$messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
|
||||
|
@ -70,7 +70,7 @@ class ArgvInput extends Input
|
||||
protected function parse()
|
||||
{
|
||||
$this->parsed = $this->tokens;
|
||||
while ($token = array_shift($this->parsed))
|
||||
while (null !== ($token = array_shift($this->parsed)))
|
||||
{
|
||||
if ('--' === substr($token, 0, 2))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user