/**
* Renders a sub-command in the "Commands" section.
*
* @param BlockLayout $layout The layout.
* @param Command $command The command to render.
*/
protected function renderSubCommand(BlockLayout $layout, Command $command)
{
$config = $command->getConfig();
$description = $config->getDescription();
$help = $config->getHelp();
$arguments = $command->getArgsFormat()->getArguments(false);
$options = $command->getArgsFormat()->getOptions(false);
if ($config instanceof OptionCommandConfig) {
if ($config->isLongNamePreferred()) {
$preferredName = '--<u>' . $config->getLongName() . '</u>';
$alternativeName = $config->getShortName() ? '-<u>' . $config->getShortName() . '</u>' : null;
} else {
$preferredName = '-<u>' . $config->getShortName() . '</u>';
$alternativeName = '--<u>' . $config->getLongName() . '</u>';
}
$name = $preferredName;
if ($alternativeName) {
$name .= ' (' . $alternativeName . ')';
}
} else {
$name = '<u>' . $command->getName() . '</u>';
}
$layout->add(new Paragraph($name));
$layout->beginBlock();
if ($description) {
$this->renderSubCommandDescription($layout, $description);
}
if ($help) {
$this->renderSubCommandHelp($layout, $help);
}
if ($arguments) {
$this->renderSubCommandArguments($layout, $arguments);
}
if ($options) {
$this->renderSubCommandOptions($layout, $options);
}
if (!$description && !$help && !$arguments && !$options) {
$layout->add(new EmptyLine());
}
$layout->endBlock();
}