-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Components/Console improvements #2074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
provided a correct answer, the ``askAndValidate`` method. Both have | ||
the disadvantage that you need to handle incorrect values yourself. | ||
|
||
Instead, you can use the ``select`` method, which makes sure that the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an API link here for the select
method.
Thanks for the input @wouterj, I'll have a look and rework the things you mentioned! |
I think you need to document all arguments, you are missing |
* ``attempts``: Maximum number of times to ask or ``false`` for infinite times | ||
(default ``false``) | ||
* ``errorMessage``: Error message to display when wrong answer is entered (default | ||
``Value "%s" is invalid``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the right approach! The parameters are documented in the API description as well as in the code. Dublicating it does not seem very good. On the other hand if the default, attempts and errorMessage should be documented, the other options should also be mentioned to make it a complete documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can do something different than put them in a list with the description.
Above, you have this:
If the user enters an invalid string, an error message is shown and the user
is asked to provide the answer another time, till he enters a valid string.
You can make it something like this:
If the user enters an invalid string, an error message is shown and the user
is asked to provide the answer another time, till he enters a valid string
or the maximum attempts is reached (which you can define in the fifth
parameter). You can define your own error message in the sixth parameter.
I did the changes you mentioned. I also commented on one of my changes I'm not sure about! |
$dialog = $app->getHelperSet()->get('dialog'); | ||
$colors = array('red', 'blue', 'yellow'); | ||
|
||
$colorKey = $dialog->select($output, 'Please select your favorite color (default to red)', $colors, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line will cause a horizontal scrollbar, I prefer something like this:
$colorKey = $dialog->select(
$output,
'Please select your favorite color (default to red)',
$colors,
0
);
Bugfixing a wording in the ProgressHelper
I improved the documentation as suggested. If the PR is ok, I would suggest I squash the commits to make a clean history before merging! |
I think it's OK, great job! (and a happy new year 🎆 ) |
Components/Console improvements
Fantastic job Sebastian - thanks for getting this done so nicely! |
As mentioned in #1811, the ProgressHelper was moved into it's own document. I didn't change any text other than the headline.
As described in #2022, the
select
method from the DialogHelper was undocumented. I added this documentation, copying the example from the symfony blog (which I hope is ok).