From 289fd087a7c7f733a614c3af25974303ba72b395 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 22 Mar 2018 17:29:10 +0100 Subject: [PATCH 1/2] Documented the setMaxSteps() method --- components/console/helpers/progressbar.rst | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/components/console/helpers/progressbar.rst b/components/console/helpers/progressbar.rst index aa1aa53ea21..fa33a9a1474 100644 --- a/components/console/helpers/progressbar.rst +++ b/components/console/helpers/progressbar.rst @@ -55,9 +55,20 @@ you can also set the current progress by calling the accordingly. By default, when using a ``max``, the redraw frequency is set to *10%* of your ``max``. -If you don't know the number of steps in advance, just omit the steps argument -when creating the :class:`Symfony\\Component\\Console\\Helper\\ProgressBar` -instance:: +If you don't know the exact number of steps in advance, set it to a reasonable +value and then call the ``setMaxSteps()`` method to updated it as needed:: + + // start with a 50 units progressbar + $progressBar = new ProgressBar($output, 50); + + // a complex task has just been created: increase the progressbar to 200 units + $progressBar->setMaxSteps(200); + +.. versionadded:: 4.1 + The ``setMaxSteps()`` method was introduced in Symfony 4.1. + +Another solution is to just omit the steps argument when creating the +:class:`Symfony\\Component\\Console\\Helper\\ProgressBar` instance:: $progressBar = new ProgressBar($output); From 6c9c2e4f9ac5da56b947d202c95257fcde0c30ab Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 23 Mar 2018 10:15:17 +0100 Subject: [PATCH 2/2] Minor fix --- components/console/helpers/progressbar.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/console/helpers/progressbar.rst b/components/console/helpers/progressbar.rst index fa33a9a1474..5b3cdec56bd 100644 --- a/components/console/helpers/progressbar.rst +++ b/components/console/helpers/progressbar.rst @@ -56,7 +56,7 @@ you can also set the current progress by calling the is set to *10%* of your ``max``. If you don't know the exact number of steps in advance, set it to a reasonable -value and then call the ``setMaxSteps()`` method to updated it as needed:: +value and then call the ``setMaxSteps()`` method to update it as needed:: // start with a 50 units progressbar $progressBar = new ProgressBar($output, 50);