Skip to content

Commit f002cea

Browse files
committed
Reworking the documentation on the DialogHelper select method
Bugfixing a wording in the ProgressHelper
1 parent 61abc95 commit f002cea

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

components/console/helpers/dialoghelper.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,21 @@ from a predefined list::
168168
$dialog = $app->getHelperSet()->get('dialog');
169169
$colors = array('red', 'blue', 'yellow');
170170
171-
$colorKey = $dialog->select($output, 'Please select your favorite color (default to red)', $colors, 0);
171+
$color = $dialog->select(
172+
$output,
173+
'Please select your favorite color (default to red)',
174+
$colors,
175+
0
176+
);
172177
$output->writeln('You have just selected: ' . $colors[$color]);
173178
174179
// ... do something with the color
175180
181+
The option which should be selected by default is provided with the fourth
182+
parameter. The default is ``null``, which means that no option is the default one.
183+
176184
If the user enters an invalid string, an error message is shown and the user
177-
is asked to provide the answer another time, till he enters a valid string.
178-
179-
The ``select`` method takes 6 parameters:
180-
181-
* ``output``: The output instance
182-
* ``question``: The question to ask
183-
* ``choices``: An array of strings with the choices the user can pick
184-
* ``default``: The index of the default value in the array or ``null`` if no
185-
default should be provided (default ``null``)
186-
* ``attempts``: Maximum number of times to ask or ``false`` for infinite times
187-
(default ``false``)
188-
* ``errorMessage``: Error message to display when wrong answer is entered (default
189-
``Value "%s" is invalid``)
185+
is asked to provide the answer another time, till he enters a valid string
186+
or the maximum attempts is reached (which you can define in the fifth
187+
parameter). The default value for the attempts is ``false``, which means infinite
188+
attempts. You can define your own error message in the sixth parameter.

components/console/helpers/progresshelper.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pass it a total number of units, and advance the progress as your command execut
2020
$progress->start($output, 50);
2121
$i = 0;
2222
while ($i++ < 50) {
23-
// do some work
23+
// ... do some work
2424

2525
// advance the progress bar 1 unit
2626
$progress->advance();

0 commit comments

Comments
 (0)