Skip to content

Commit 9a4265d

Browse files
committed
[Console] Documented the setMaxSteps() method
1 parent 8e64505 commit 9a4265d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

components/console/helpers/progressbar.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,20 @@ you can also set the current progress by calling the
5555
accordingly. By default, when using a ``max``, the redraw frequency
5656
is set to *10%* of your ``max``.
5757

58-
If you don't know the number of steps in advance, just omit the steps argument
59-
when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar`
60-
instance::
58+
If you don't know the exact number of steps in advance, set it to a reasonable
59+
value and then call the ``setMaxSteps()`` method to update it as needed::
60+
61+
// start with a 50 units progressbar
62+
$progressBar = new ProgressBar($output, 50);
63+
64+
// a complex task has just been created: increase the progressbar to 200 units
65+
$progressBar->setMaxSteps(200);
66+
67+
.. versionadded:: 4.1
68+
The ``setMaxSteps()`` method was introduced in Symfony 4.1.
69+
70+
Another solution is to just omit the steps argument when creating the
71+
:class:`Symfony\\Component\\Console\\Helper\\ProgressBar` instance::
6172

6273
$progressBar = new ProgressBar($output);
6374

0 commit comments

Comments
 (0)