-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Add 2 solutions for the 'option with optional argument' problem #9560
Conversation
Hi @Jean85! Thanks a lot for this PR, it seems to read nicer this way! I like your second option way more than your first one. The first one is some internal logic, which the framework wants to hide from you by providing the input options and arguments. What do you think about only documenting the second option? Giving readers a choice means we have to explain in which case to use (1) or (2), and I can't come up with a reason to use (1). :) I'm sorry to have such a delayed review of this PR. If you can comment or update the PR, please do so and otherwise I'm happy to take this PR over to make it mergable :) |
No problem @wouterj! I've simplified my PR leaving just (2). Now it's back to you to review 😉 |
@Jean85 thanks for taking the time to improve the docs about this. It's an edge-case, but it's important to explain it well. I did some rewords to simplify some phrases and replace some advanced English words for other basic words (we need to do that to keep the docs approachable for people without an advanced English level). We merged it on 2.8 (the oldest maintained branch) |
…roblem (Jean85, javiereguiluz) This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #9560). Discussion ---------- Add 2 solutions for the 'option with optional argument' problem While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said: > There is nothing forbidding you to create a command with an option that optionally accepts a value. However, there is no way you can distinguish when the option was used without a value (command --language) or when it wasn't used at all (command). In both cases, the value retrieved for the option will be null. This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me. Commits ------- d3f254d Minor simplifications 1aad365 Minor reword 99f9e3f Simplify the explanation leaving just one solution a05b002 Add 2 solutions for the 'option with optional argument' problem
…roblem (Jean85, javiereguiluz) This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #9560). Discussion ---------- Add 2 solutions for the 'option with optional argument' problem While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said: > There is nothing forbidding you to create a command with an option that optionally accepts a value. However, there is no way you can distinguish when the option was used without a value (command --language) or when it wasn't used at all (command). In both cases, the value retrieved for the option will be null. This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me. Commits ------- 7be002b Add 2 solutions for the 'option with optional argument' problem
While working on facile-it/paraunit#121, I discovered a tricky case with the Console component: using an option with an optional argument seemed impossible! The doc said:
This is NOT TRUE. I've found two possible solutions to this issue (one myself, one in symfony/symfony#11572 (comment)) and this PR introduces them in the docs. I've also moved around the two tips/cautions which were at the end of the article, because with my reword it seemed nicer to me.