[Console] Fix wrong handling of multiline arg/opt descriptions
This commit is contained in:
parent
c360a222ef
commit
18fc6b54da
@ -38,13 +38,13 @@ class TextDescriptor extends Descriptor
|
|||||||
}
|
}
|
||||||
|
|
||||||
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
|
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
|
||||||
$spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
|
$spacingWidth = $totalWidth - strlen($argument->getName());
|
||||||
|
|
||||||
$this->writeText(sprintf(' <info>%s</info>%s%s%s',
|
$this->writeText(sprintf(' <info>%s</info> %s%s%s',
|
||||||
$argument->getName(),
|
$argument->getName(),
|
||||||
str_repeat(' ', $spacingWidth),
|
str_repeat(' ', $spacingWidth),
|
||||||
// + 17 = 2 spaces + <info> + </info> + 2 spaces
|
// + 4 = 2 spaces before <info>, 2 spaces after </info>
|
||||||
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
|
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
|
||||||
$default
|
$default
|
||||||
), $options);
|
), $options);
|
||||||
}
|
}
|
||||||
@ -75,13 +75,13 @@ class TextDescriptor extends Descriptor
|
|||||||
sprintf('--%s%s', $option->getName(), $value)
|
sprintf('--%s%s', $option->getName(), $value)
|
||||||
);
|
);
|
||||||
|
|
||||||
$spacingWidth = $totalWidth - strlen($synopsis) + 2;
|
$spacingWidth = $totalWidth - strlen($synopsis);
|
||||||
|
|
||||||
$this->writeText(sprintf(' <info>%s</info>%s%s%s%s',
|
$this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
|
||||||
$synopsis,
|
$synopsis,
|
||||||
str_repeat(' ', $spacingWidth),
|
str_repeat(' ', $spacingWidth),
|
||||||
// + 17 = 2 spaces + <info> + </info> + 2 spaces
|
// + 4 = 2 spaces before <info>, 2 spaces after </info>
|
||||||
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
|
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
|
||||||
$default,
|
$default,
|
||||||
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
|
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
|
||||||
), $options);
|
), $options);
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<info>argument_name</info> multiline
|
<info>argument_name</info> multiline
|
||||||
argument description
|
argument description
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<info>-o, --option_name=OPTION_NAME</info> multiline
|
<info>-o, --option_name=OPTION_NAME</info> multiline
|
||||||
option description
|
option description
|
||||||
|
Reference in New Issue
Block a user