Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18fc6b5

Browse filesBrowse files
committed
[Console] Fix wrong handling of multiline arg/opt descriptions
1 parent c360a22 commit 18fc6b5
Copy full SHA for 18fc6b5

File tree

3 files changed

+10
-10
lines changed
Filter options

3 files changed

+10
-10
lines changed

‎src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Descriptor/TextDescriptor.php
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ protected function describeInputArgument(InputArgument $argument, array $options
3838
}
3939

4040
$totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
41-
$spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
41+
$spacingWidth = $totalWidth - strlen($argument->getName());
4242

43-
$this->writeText(sprintf(' <info>%s</info>%s%s%s',
43+
$this->writeText(sprintf(' <info>%s</info> %s%s%s',
4444
$argument->getName(),
4545
str_repeat(' ', $spacingWidth),
46-
// + 17 = 2 spaces + <info> + </info> + 2 spaces
47-
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $argument->getDescription()),
46+
// + 4 = 2 spaces before <info>, 2 spaces after </info>
47+
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
4848
$default
4949
), $options);
5050
}
@@ -75,13 +75,13 @@ protected function describeInputOption(InputOption $option, array $options = arr
7575
sprintf('--%s%s', $option->getName(), $value)
7676
);
7777

78-
$spacingWidth = $totalWidth - strlen($synopsis) + 2;
78+
$spacingWidth = $totalWidth - strlen($synopsis);
7979

80-
$this->writeText(sprintf(' <info>%s</info>%s%s%s%s',
80+
$this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
8181
$synopsis,
8282
str_repeat(' ', $spacingWidth),
83-
// + 17 = 2 spaces + <info> + </info> + 2 spaces
84-
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 17), $option->getDescription()),
83+
// + 4 = 2 spaces before <info>, 2 spaces after </info>
84+
preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
8585
$default,
8686
$option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
8787
), $options);
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<info>argument_name</info> multiline
2-
argument description
2+
argument description
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<info>-o, --option_name=OPTION_NAME</info> multiline
2-
option description
2+
option description

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.