[Console] Show aliases in command description instead of in different lines in application description
This commit is contained in:
parent
ea9d6e7235
commit
548ab0a176
@ -198,6 +198,8 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add commands by namespace
|
// add commands by namespace
|
||||||
|
$commands = $description->getCommands();
|
||||||
|
|
||||||
foreach ($description->getNamespaces() as $namespace) {
|
foreach ($description->getNamespaces() as $namespace) {
|
||||||
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
|
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
@ -205,9 +207,13 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($namespace['commands'] as $name) {
|
foreach ($namespace['commands'] as $name) {
|
||||||
|
if (isset($commands[$name])) {
|
||||||
$this->writeText("\n");
|
$this->writeText("\n");
|
||||||
$spacingWidth = $width - strlen($name);
|
$spacingWidth = $width - strlen($name);
|
||||||
$this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
|
$command = $commands[$name];
|
||||||
|
$commandAliases = $this->getCommandAliasesText($command);
|
||||||
|
$this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +232,25 @@ class TextDescriptor extends Descriptor
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats command aliases to show them in the command description.
|
||||||
|
*
|
||||||
|
* @param Command $command
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getCommandAliasesText($command)
|
||||||
|
{
|
||||||
|
$text = '';
|
||||||
|
$aliases = $command->getAliases();
|
||||||
|
|
||||||
|
if ($aliases) {
|
||||||
|
$text = '['.implode('|', $aliases).'] ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats input option/argument default value.
|
* Formats input option/argument default value.
|
||||||
*
|
*
|
||||||
|
@ -13,10 +13,8 @@
|
|||||||
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
<info>-v|vv|vvv, --verbose</info> Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||||
|
|
||||||
<comment>Available commands:</comment>
|
<comment>Available commands:</comment>
|
||||||
<info>alias1</info> command 1 description
|
|
||||||
<info>alias2</info> command 1 description
|
|
||||||
<info>help</info> Displays help for a command
|
<info>help</info> Displays help for a command
|
||||||
<info>list</info> Lists commands
|
<info>list</info> Lists commands
|
||||||
<comment>descriptor</comment>
|
<comment>descriptor</comment>
|
||||||
<info>descriptor:command1</info> command 1 description
|
<info>descriptor:command1</info> [alias1|alias2] command 1 description
|
||||||
<info>descriptor:command2</info> command 2 description
|
<info>descriptor:command2</info> command 2 description
|
||||||
|
Reference in New Issue
Block a user