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 ff0ccde

Browse filesBrowse files
Reworded the description
1 parent 31a2a44 commit ff0ccde
Copy full SHA for ff0ccde

File tree

1 file changed

+18
-14
lines changed
Filter options

1 file changed

+18
-14
lines changed

‎console/style.rst

Copy file name to clipboardExpand all lines: console/style.rst
+18-14Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -377,27 +377,31 @@ of your commands to change their appearance::
377377
Writing to the error output
378378
---------------------------
379379

380-
If you rely on the output of a command (e.g. by redirecting it to a file for later reuse),
381-
you may want to get only the relevant information outputted by the command, excluding progress
382-
bars, notes, warnings and other error messages which have, most of the time, no value for reuse.
380+
If you reuse the output of a command as the input of other commands or dump it
381+
into a file for later reuse, you probably want to exclude progress bars, notes
382+
and other output that provides no real value.
383383

384-
For excluding irrelevant messages from the output, you need to make your command write them to the error
385-
output. Fortunately, the :class:`Symfony\\Component\\Console\\Style\\SymfonyStyle` provides a convenient
386-
method to easily switch between both outputs:
387-
:method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::getErrorStyle`.
388-
This method returns a new ``SymfonyStyle`` instance which makes use of the error output:
384+
Commands can output information in two different streams: ``stdout`` (standard
385+
output) is the stream where the real contents should be output and ``stderr``
386+
(standard error) is the stream where the errors and the debugging messages
387+
should be output.
388+
389+
The :class:`Symfony\\Component\\Console\\Style\\SymfonyStyle` class provides a
390+
convenient method called :method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::getErrorStyle`
391+
to switch between both streams. This method returns a new ``SymfonyStyle``
392+
instance which makes use of the error output::
389393

390394
$io = new SymfonyStyle($input, $output);
391395

392-
// Write to the output
396+
// Write to the standard output
393397
$io->write('Reusable information');
394398

395399
// Write to the error output
396-
$io->getErrorStyle()->warning('Irrelevant warning');
400+
$io->getErrorStyle()->warning('Debugging information or errors');
397401

398402
.. note::
399403

400-
If you created the original ``SymfonyStyle`` instance with an ``OutputInterface`` object that is
401-
not an instance of :class:`Symfony\\Component\\Console\\Output\\ConsoleOutputInterface`, using
402-
``getErrorStyle()`` will return an instance which makes use of the normal output instead of
403-
the error one, as if you did not called the method.
404+
If you create a ``SymfonyStyle`` instance with an ``OutputInterface`` object
405+
that is not an instance of :class:`Symfony\\Component\\Console\\Output\\ConsoleOutputInterface`,
406+
the ``getErrorStyle()`` method will have no effect and the returned object
407+
will still output to the standard output instead of the error output.

0 commit comments

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