}
// add commands by namespace
+ $commands = $description->getCommands();
+
foreach ($description->getNamespaces() as $namespace) {
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
$this->writeText("\n");
}
foreach ($namespace['commands'] as $name) {
- $this->writeText("\n");
- $spacingWidth = $width - Helper::strlen($name);
- $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
+ if (isset($commands[$name])) {
+ $this->writeText("\n");
+ $spacingWidth = $width - Helper::strlen($name);
+ $command = $commands[$name];
+ $commandAliases = $this->getCommandAliasesText($command);
+ $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
+ }
}
}
);
}
+ /**
+ * 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.
*
*/
private function formatDefaultValue($default)
{
+ if (INF === $default) {
+ return 'INF';
+ }
+
if (is_string($default)) {
$default = OutputFormatter::escape($default);
} elseif (is_array($default)) {
}
}
- if (\PHP_VERSION_ID < 50400) {
- return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
- }
-
return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}
$totalWidth = 0;
foreach ($options as $option) {
// "-" + shortcut + ", --" + name
- $nameLength = 1 + max(strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
+ $nameLength = 1 + max(Helper::strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
if ($option->acceptValue()) {
$valueLength = 1 + Helper::strlen($option->getName()); // = + value