Skip to content

Commit ff0ccde

Browse files
Reworded the description
1 parent 31a2a44 commit ff0ccde

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

console/style.rst

+18-14
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)