Skip to content

Commit

Permalink
[#15270] Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Jun 17, 2021
1 parent fb749b5 commit 7565926
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .doctor-rst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ whitelist:
- '.. code-block:: twig'
- '.. versionadded:: 3.6' # MonologBundle
- 'End to End Tests (E2E)'
- '.. code-block:: php'
17 changes: 10 additions & 7 deletions components/console/helpers/cursor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Cursor Helper

.. versionadded:: 5.1

The :class:`Symfony\\Component\\Console\\Cursor`
class was introduced in Symfony 5.1.
The :class:`Symfony\\Component\\Console\\Cursor` class was introduced
in Symfony 5.1.

The :class:`Symfony\\Component\\Console\\Cursor` allows you to change the
cursor position in a console command. This allows you to write on any position
Expand All @@ -16,10 +16,11 @@ of the output:
.. image:: /_images/components/console/cursor.gif
:align: center


.. code-block:: php
// src/Commande/MyCommand.php
// src/Command/MyCommand.php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Cursor;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -29,13 +30,14 @@ of the output:
{
// ...
public function execute(InputInterface $input, OutputInterface $output)
public function execute(InputInterface $input, OutputInterface $output): int
{
// ...
$cursor = new Cursor($output);
// moves the cursor to a specific column and row position
// moves the cursor to a specific column (1st argument) and
// row (2nd argument) position
$cursor->moveToPosition(7, 11);
// and write text on this position using the output
Expand Down Expand Up @@ -71,7 +73,8 @@ There are fews methods to control moving the command cursor::
// same for left
$cursor->moveLeft();

// move the cursor to a specific position from its current position
// move the cursor to a specific (column, row) position from the
// top-left position of the terminal
$cursor->moveToPosition(7, 11);

You can get the current command's cursor position by using::
Expand Down

0 comments on commit 7565926

Please sign in to comment.