Adding feature to Command help that allows you to use %command.name% and %command.full_name% patterns so you don't have to hardcode the command name in help text.
This commit is contained in:
parent
27057fe6ae
commit
0c78e9f121
@ -381,6 +381,28 @@ class Command
|
|||||||
return $this->help;
|
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.
|
* Sets the aliases for the command.
|
||||||
*
|
*
|
||||||
@ -463,7 +485,7 @@ class Command
|
|||||||
|
|
||||||
$messages[] = $this->definition->asText();
|
$messages[] = $this->definition->asText();
|
||||||
|
|
||||||
if ($help = $this->getHelp())
|
if ($help = $this->getProcessedHelp())
|
||||||
{
|
{
|
||||||
$messages[] = '<comment>Help:</comment>';
|
$messages[] = '<comment>Help:</comment>';
|
||||||
$messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
|
$messages[] = ' '.implode("\n ", explode("\n", $help))."\n";
|
||||||
|
Reference in New Issue
Block a user