feature #15964 Symfony Console Style tweaks (javiereguiluz)

This PR was squashed before being merged into the 2.8 branch (closes #15964).

Discussion
----------

Symfony Console Style tweaks

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR will contain some minor tweaks found while updating all the Symfony commands. Don't merge yet. Thanks!

Commits
-------

64e7b6f Symfony Console Style tweaks
This commit is contained in:
Fabien Potencier 2015-09-28 23:11:06 +02:00
commit 5322cbbca8
4 changed files with 29 additions and 9 deletions

View File

@ -110,7 +110,7 @@ class SymfonyStyle extends OutputStyle
$this->autoPrependBlock();
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('=', strlen($message))),
sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
));
$this->newLine();
}
@ -123,7 +123,7 @@ class SymfonyStyle extends OutputStyle
$this->autoPrependBlock();
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('-', strlen($message))),
sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
));
$this->newLine();
}
@ -149,14 +149,22 @@ class SymfonyStyle extends OutputStyle
{
$this->autoPrependText();
if (!is_array($message)) {
$this->writeln(sprintf(' // %s', $message));
return;
$messages = is_array($message) ? array_values($message) : array($message);
foreach ($messages as $message) {
$this->writeln(sprintf(' %s', $message));
}
}
foreach ($message as $element) {
$this->text($element);
/**
* {@inheritdoc}
*/
public function comment($message)
{
$this->autoPrependText();
$messages = is_array($message) ? array_values($message) : array($message);
foreach ($messages as $message) {
$this->writeln(sprintf(' // %s', $message));
}
}

View File

@ -26,4 +26,12 @@ return function (InputInterface $input, OutputInterface $output) {
'Lorem ipsum dolor sit amet',
'consectetur adipiscing elit',
));
$output->newLine();
$output->write('Lorem ipsum dolor sit amet');
$output->comment(array(
'Lorem ipsum dolor sit amet',
'consectetur adipiscing elit',
));
};

View File

@ -6,6 +6,10 @@ Lorem ipsum dolor sit amet
* Lorem ipsum dolor sit amet
* consectetur adipiscing elit
Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet
consectetur adipiscing elit
Lorem ipsum dolor sit amet
// Lorem ipsum dolor sit amet
// consectetur adipiscing elit

View File

@ -2,4 +2,4 @@
Title
=====
// Duis aute irure dolor in reprehenderit in voluptate velit esse
Duis aute irure dolor in reprehenderit in voluptate velit esse